From 5cebb04786e75b014baf3dba37f8fe6cd363cd26 Mon Sep 17 00:00:00 2001 From: David Odin Date: Thu, 6 Dec 2001 02:32:57 +0000 Subject: [PATCH] use the G_N_ELEMENTS macro where appropriate, removing a bunch of unuseful static variables. Changed some g_malloc to g_new while I was on it. --- plug-ins/script-fu/scheme-wrapper.c | 2 +- plug-ins/script-fu/script-fu.c | 15 +++++---------- plug-ins/script-fu/siod-wrapper.c | 2 +- plug-ins/sel2path/sel2path.c | 6 ++---- plug-ins/sgi/sgi.c | 10 +++------- plug-ins/webbrowser/webbrowser.c | 3 +-- plug-ins/xjt/xjt.c | 9 +++------ 7 files changed, 16 insertions(+), 31 deletions(-) diff --git a/plug-ins/script-fu/scheme-wrapper.c b/plug-ins/script-fu/scheme-wrapper.c index 7a64ef028c..73905352f1 100644 --- a/plug-ins/script-fu/scheme-wrapper.c +++ b/plug-ins/script-fu/scheme-wrapper.c @@ -109,7 +109,7 @@ siod_init (gint local_register_scripts) register_scripts = local_register_scripts; /* init the interpreter */ - process_cla (sizeof (siod_argv) / sizeof (char *), siod_argv, 1); + process_cla (G_N_ELEMENTS (siod_argv), siod_argv, 1); init_storage (); init_subrs (); init_trace (); diff --git a/plug-ins/script-fu/script-fu.c b/plug-ins/script-fu/script-fu.c index 762bab757d..0da56dc606 100644 --- a/plug-ins/script-fu/script-fu.c +++ b/plug-ins/script-fu/script-fu.c @@ -86,20 +86,17 @@ script_fu_query (void) { { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" } }; - static gint nconsole_args = sizeof (console_args) / sizeof (console_args[0]); static GimpParamDef textconsole_args[] = { { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" } }; - static gint ntextconsole_args = sizeof (textconsole_args) / sizeof (textconsole_args[0]); static GimpParamDef eval_args[] = { { GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" }, { GIMP_PDB_STRING, "code", "The code to evaluate" } }; - static gint neval_args = sizeof (eval_args) / sizeof (eval_args[0]); static GimpParamDef server_args[] = { @@ -107,7 +104,6 @@ script_fu_query (void) { GIMP_PDB_INT32, "port", "The port on which to listen for requests" }, { GIMP_PDB_STRING, "logfile", "The file to log server activity to" } }; - static gint nserver_args = sizeof (server_args) / sizeof (server_args[0]); gimp_plugin_domain_register ("gimp-script-fu", NULL); @@ -131,7 +127,7 @@ script_fu_query (void) N_("/Xtns/Script-Fu/Console..."), NULL, GIMP_EXTENSION, - nconsole_args, 0, + G_N_ELEMENTS (console_args), 0, console_args, NULL); gimp_install_procedure ("extension_script_fu_text_console", @@ -143,7 +139,7 @@ script_fu_query (void) NULL, NULL, GIMP_EXTENSION, - ntextconsole_args, 0, + G_N_ELEMENTS (textconsole_args), 0, textconsole_args, NULL); #ifndef G_OS_WIN32 @@ -156,7 +152,7 @@ script_fu_query (void) N_("/Xtns/Script-Fu/Server..."), NULL, GIMP_EXTENSION, - nserver_args, 0, + G_N_ELEMENTS (server_args), 0, server_args, NULL); #endif @@ -169,7 +165,7 @@ script_fu_query (void) NULL, NULL, GIMP_EXTENSION, - neval_args, 0, + G_N_ELEMENTS (eval_args), 0, eval_args, NULL); } @@ -275,7 +271,6 @@ script_fu_auxillary_init (void) { { GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" } }; - static gint nargs = sizeof (args) / sizeof (args[0]); gimp_install_temp_proc ("script_fu_refresh", _("Re-read all available scripts"), @@ -286,7 +281,7 @@ script_fu_auxillary_init (void) N_("/Xtns/Script-Fu/Refresh"), NULL, GIMP_TEMPORARY, - nargs, 0, + G_N_ELEMENTS (args), 0, args, NULL, script_fu_refresh_proc); } diff --git a/plug-ins/script-fu/siod-wrapper.c b/plug-ins/script-fu/siod-wrapper.c index 7a64ef028c..73905352f1 100644 --- a/plug-ins/script-fu/siod-wrapper.c +++ b/plug-ins/script-fu/siod-wrapper.c @@ -109,7 +109,7 @@ siod_init (gint local_register_scripts) register_scripts = local_register_scripts; /* init the interpreter */ - process_cla (sizeof (siod_argv) / sizeof (char *), siod_argv, 1); + process_cla (G_N_ELEMENTS (siod_argv), siod_argv, 1); init_storage (); init_subrs (); init_trace (); diff --git a/plug-ins/sel2path/sel2path.c b/plug-ins/sel2path/sel2path.c index b05a744954..ffdabe7716 100644 --- a/plug-ins/sel2path/sel2path.c +++ b/plug-ins/sel2path/sel2path.c @@ -120,7 +120,6 @@ query_2 (void) { GIMP_PDB_INT8, "tangent_surround", "tangent_surround"}, }; static GimpParamDef *return_vals = NULL; - static int nargs = sizeof (args) / sizeof (args[0]); static int nreturn_vals = 0; gimp_install_procedure ("plug_in_sel2path_advanced", @@ -132,7 +131,7 @@ query_2 (void) NULL, "RGB*, INDEXED*, GRAY*", GIMP_PLUGIN, - nargs, nreturn_vals, + G_N_ELEMENTS (args), nreturn_vals, args, return_vals); } @@ -146,7 +145,6 @@ query (void) { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, }; static GimpParamDef *return_vals = NULL; - static int nargs = sizeof (args) / sizeof (args[0]); static int nreturn_vals = 0; INIT_I18N(); @@ -160,7 +158,7 @@ query (void) N_("/Select/To Path"), "RGB*, INDEXED*, GRAY*", GIMP_PLUGIN, - nargs, nreturn_vals, + G_N_ELEMENTS (args), nreturn_vals, args, return_vals); query_2 (); diff --git a/plug-ins/sgi/sgi.c b/plug-ins/sgi/sgi.c index 8c7bcbc493..7c16a01cf7 100644 --- a/plug-ins/sgi/sgi.c +++ b/plug-ins/sgi/sgi.c @@ -104,9 +104,6 @@ query (void) { { GIMP_PDB_IMAGE, "image", "Output image" }, }; - static gint nload_args = sizeof (load_args) / sizeof (load_args[0]); - static gint nload_return_vals = (sizeof (load_return_vals) / - sizeof (load_return_vals[0])); static GimpParamDef save_args[] = { @@ -117,7 +114,6 @@ query (void) { GIMP_PDB_STRING, "raw_filename", "The name of the file to save the image in" }, { GIMP_PDB_INT32, "compression", "Compression level (0 = none, 1 = RLE, 2 = ARLE)" } }; - static gint nsave_args = sizeof (save_args) / sizeof (save_args[0]); INIT_I18N(); @@ -130,8 +126,8 @@ query (void) "/SGI", NULL, GIMP_PLUGIN, - nload_args, - nload_return_vals, + G_N_ELEMENTS (load_args), + G_N_ELEMENTS (load_return_vals), load_args, load_return_vals); @@ -144,7 +140,7 @@ query (void) "/SGI", "RGB*,GRAY*", GIMP_PLUGIN, - nsave_args, + G_N_ELEMENTS (save_args), 0, save_args, NULL); diff --git a/plug-ins/webbrowser/webbrowser.c b/plug-ins/webbrowser/webbrowser.c index 02293de18c..0302bc4c40 100644 --- a/plug-ins/webbrowser/webbrowser.c +++ b/plug-ins/webbrowser/webbrowser.c @@ -130,7 +130,6 @@ query (void) { GIMP_PDB_STRING, "url", "URL of a document to open" }, { GIMP_PDB_INT32, "new_window", "Create a new window or use existing one?" }, }; - static gint nargs = sizeof (args) / sizeof (args[0]); gimp_install_procedure ("extension_web_browser", "open URL in Netscape", @@ -141,7 +140,7 @@ query (void) N_("/Xtns/Web Browser/Open URL..."), NULL, GIMP_EXTENSION, - nargs, 0, + G_N_ELEMENTS (args), 0, args, NULL); } diff --git a/plug-ins/xjt/xjt.c b/plug-ins/xjt/xjt.c index 9ce0707e20..90faa81734 100644 --- a/plug-ins/xjt/xjt.c +++ b/plug-ins/xjt/xjt.c @@ -447,9 +447,6 @@ query (void) { { GIMP_PDB_IMAGE, "image", "Output image" }, }; - static gint nload_args = sizeof (load_args) / sizeof (load_args[0]); - static gint nload_return_vals = (sizeof (load_return_vals) / - sizeof (load_return_vals[0])); static GimpParamDef save_args[] = { @@ -463,7 +460,6 @@ query (void) { GIMP_PDB_INT32, "optimize", "Optimization of entropy encoding parameters" }, { GIMP_PDB_INT32, "clr_transparent", "set all full-transparent pixels to 0" }, }; - static gint nsave_args = sizeof (save_args) / sizeof (save_args[0]); INIT_I18N (); @@ -476,7 +472,8 @@ query (void) "/xjt", NULL, GIMP_PLUGIN, - nload_args, nload_return_vals, + G_N_ELEMENTS (load_args), + G_N_ELEMENTS (load_return_vals), load_args, load_return_vals); gimp_install_procedure ("file_xjt_save", @@ -488,7 +485,7 @@ query (void) "/xjt", "RGB*, GRAY*", GIMP_PLUGIN, - nsave_args, 0, + G_N_ELEMENTS (save_args), 0, save_args, NULL); gimp_register_magic_load_handler ("file_xjt_load",