cleanup: Consolidate countof macros.

This commit is contained in:
2024-11-13 20:22:42 -05:00
parent 5bdf970c10
commit 53e75d8209
10 changed files with 26 additions and 48 deletions

View File

@ -39,10 +39,6 @@
#include "jni.h"
#endif
#if !defined(_countof)
#define _countof(a) ((int)(sizeof((a)) / sizeof(*(a))))
#endif
struct backtrace_state* g_backtrace_state;
const char* k_db_path_default = "db.sqlite";
@ -264,7 +260,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[])
"ssb",
"todo",
};
for (int i = 0; i < (int)_countof(k_export); i++)
for (int i = 0; i < tf_countof(k_export); i++)
{
char buffer[256];
snprintf(buffer, sizeof(buffer), "/~%s/%s", user, k_export[i]);
@ -778,7 +774,7 @@ static int _tf_command_usage(const char* file)
{
tf_printf("Usage: %s command [command-options]\n", file);
tf_printf("commands:\n");
for (int i = 0; i < (int)_countof(k_commands); i++)
for (int i = 0; i < tf_countof(k_commands); i++)
{
tf_printf(" %s - %s\n", k_commands[i].name, k_commands[i].description);
}
@ -908,7 +904,7 @@ static jint _tf_server_main(JNIEnv* env, jobject this_object, jstring files_dir,
};
tf_task_set_android_service_callbacks(_tf_service_start, _tf_service_stop);
result = _tf_command_run(apk, _countof(args), (char**)args);
result = _tf_command_run(apk, tf_countof(args), (char**)args);
tf_task_set_android_service_callbacks(NULL, NULL);
(*env)->ReleaseStringUTFChars(env, files_dir, files);
@ -939,7 +935,7 @@ static jint _tf_sandbox_main(JNIEnv* env, jobject this_object, int pipe_fd)
fd,
};
int result = _tf_command_sandbox(NULL, _countof(args), (char**)args);
int result = _tf_command_sandbox(NULL, tf_countof(args), (char**)args);
tf_mem_shutdown();
tf_printf("tf_sandbox_main finished with %d.", result);
@ -971,7 +967,7 @@ JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
{ "tf_server_main", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/net/ConnectivityManager;)I", _tf_server_main },
{ "tf_sandbox_main", "(I)I", _tf_sandbox_main },
};
int result = (*env)->RegisterNatives(env, c, methods, (int)_countof(methods));
int result = (*env)->RegisterNatives(env, c, methods, tf_countof(methods));
if (result != JNI_OK)
{
return result;
@ -1018,7 +1014,7 @@ int main(int argc, char* argv[])
int result = 0;
if (argc >= 2)
{
for (int i = 0; i < (int)_countof(k_commands); i++)
for (int i = 0; i < tf_countof(k_commands); i++)
{
const command_t* command = &k_commands[i];
if (strcmp(argv[1], command->name) == 0)