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.
This commit is contained in:
David Odin
2001-12-06 02:32:57 +00:00
parent aa201cade4
commit 5cebb04786
7 changed files with 16 additions and 31 deletions

View File

@ -109,7 +109,7 @@ siod_init (gint local_register_scripts)
register_scripts = local_register_scripts; register_scripts = local_register_scripts;
/* init the interpreter */ /* 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_storage ();
init_subrs (); init_subrs ();
init_trace (); init_trace ();

View File

@ -86,20 +86,17 @@ script_fu_query (void)
{ {
{ GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" } { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
}; };
static gint nconsole_args = sizeof (console_args) / sizeof (console_args[0]);
static GimpParamDef textconsole_args[] = static GimpParamDef textconsole_args[] =
{ {
{ GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" } { GIMP_PDB_INT32, "run_mode", "Interactive, [non-interactive]" }
}; };
static gint ntextconsole_args = sizeof (textconsole_args) / sizeof (textconsole_args[0]);
static GimpParamDef eval_args[] = static GimpParamDef eval_args[] =
{ {
{ GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" }, { GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" },
{ GIMP_PDB_STRING, "code", "The code to evaluate" } { GIMP_PDB_STRING, "code", "The code to evaluate" }
}; };
static gint neval_args = sizeof (eval_args) / sizeof (eval_args[0]);
static GimpParamDef server_args[] = 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_INT32, "port", "The port on which to listen for requests" },
{ GIMP_PDB_STRING, "logfile", "The file to log server activity to" } { 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); gimp_plugin_domain_register ("gimp-script-fu", NULL);
@ -131,7 +127,7 @@ script_fu_query (void)
N_("<Toolbox>/Xtns/Script-Fu/Console..."), N_("<Toolbox>/Xtns/Script-Fu/Console..."),
NULL, NULL,
GIMP_EXTENSION, GIMP_EXTENSION,
nconsole_args, 0, G_N_ELEMENTS (console_args), 0,
console_args, NULL); console_args, NULL);
gimp_install_procedure ("extension_script_fu_text_console", gimp_install_procedure ("extension_script_fu_text_console",
@ -143,7 +139,7 @@ script_fu_query (void)
NULL, NULL,
NULL, NULL,
GIMP_EXTENSION, GIMP_EXTENSION,
ntextconsole_args, 0, G_N_ELEMENTS (textconsole_args), 0,
textconsole_args, NULL); textconsole_args, NULL);
#ifndef G_OS_WIN32 #ifndef G_OS_WIN32
@ -156,7 +152,7 @@ script_fu_query (void)
N_("<Toolbox>/Xtns/Script-Fu/Server..."), N_("<Toolbox>/Xtns/Script-Fu/Server..."),
NULL, NULL,
GIMP_EXTENSION, GIMP_EXTENSION,
nserver_args, 0, G_N_ELEMENTS (server_args), 0,
server_args, NULL); server_args, NULL);
#endif #endif
@ -169,7 +165,7 @@ script_fu_query (void)
NULL, NULL,
NULL, NULL,
GIMP_EXTENSION, GIMP_EXTENSION,
neval_args, 0, G_N_ELEMENTS (eval_args), 0,
eval_args, NULL); eval_args, NULL);
} }
@ -275,7 +271,6 @@ script_fu_auxillary_init (void)
{ {
{ GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" } { GIMP_PDB_INT32, "run_mode", "[Interactive], non-interactive" }
}; };
static gint nargs = sizeof (args) / sizeof (args[0]);
gimp_install_temp_proc ("script_fu_refresh", gimp_install_temp_proc ("script_fu_refresh",
_("Re-read all available scripts"), _("Re-read all available scripts"),
@ -286,7 +281,7 @@ script_fu_auxillary_init (void)
N_("<Toolbox>/Xtns/Script-Fu/Refresh"), N_("<Toolbox>/Xtns/Script-Fu/Refresh"),
NULL, NULL,
GIMP_TEMPORARY, GIMP_TEMPORARY,
nargs, 0, G_N_ELEMENTS (args), 0,
args, NULL, args, NULL,
script_fu_refresh_proc); script_fu_refresh_proc);
} }

View File

@ -109,7 +109,7 @@ siod_init (gint local_register_scripts)
register_scripts = local_register_scripts; register_scripts = local_register_scripts;
/* init the interpreter */ /* 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_storage ();
init_subrs (); init_subrs ();
init_trace (); init_trace ();

View File

@ -120,7 +120,6 @@ query_2 (void)
{ GIMP_PDB_INT8, "tangent_surround", "tangent_surround"}, { GIMP_PDB_INT8, "tangent_surround", "tangent_surround"},
}; };
static GimpParamDef *return_vals = NULL; static GimpParamDef *return_vals = NULL;
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = 0; static int nreturn_vals = 0;
gimp_install_procedure ("plug_in_sel2path_advanced", gimp_install_procedure ("plug_in_sel2path_advanced",
@ -132,7 +131,7 @@ query_2 (void)
NULL, NULL,
"RGB*, INDEXED*, GRAY*", "RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN, GIMP_PLUGIN,
nargs, nreturn_vals, G_N_ELEMENTS (args), nreturn_vals,
args, return_vals); args, return_vals);
} }
@ -146,7 +145,6 @@ query (void)
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" }, { GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
}; };
static GimpParamDef *return_vals = NULL; static GimpParamDef *return_vals = NULL;
static int nargs = sizeof (args) / sizeof (args[0]);
static int nreturn_vals = 0; static int nreturn_vals = 0;
INIT_I18N(); INIT_I18N();
@ -160,7 +158,7 @@ query (void)
N_("<Image>/Select/To Path"), N_("<Image>/Select/To Path"),
"RGB*, INDEXED*, GRAY*", "RGB*, INDEXED*, GRAY*",
GIMP_PLUGIN, GIMP_PLUGIN,
nargs, nreturn_vals, G_N_ELEMENTS (args), nreturn_vals,
args, return_vals); args, return_vals);
query_2 (); query_2 ();

View File

@ -104,9 +104,6 @@ query (void)
{ {
{ GIMP_PDB_IMAGE, "image", "Output image" }, { 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[] = 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_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)" } { 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(); INIT_I18N();
@ -130,8 +126,8 @@ query (void)
"<Load>/SGI", "<Load>/SGI",
NULL, NULL,
GIMP_PLUGIN, GIMP_PLUGIN,
nload_args, G_N_ELEMENTS (load_args),
nload_return_vals, G_N_ELEMENTS (load_return_vals),
load_args, load_args,
load_return_vals); load_return_vals);
@ -144,7 +140,7 @@ query (void)
"<Save>/SGI", "<Save>/SGI",
"RGB*,GRAY*", "RGB*,GRAY*",
GIMP_PLUGIN, GIMP_PLUGIN,
nsave_args, G_N_ELEMENTS (save_args),
0, 0,
save_args, save_args,
NULL); NULL);

View File

@ -130,7 +130,6 @@ query (void)
{ GIMP_PDB_STRING, "url", "URL of a document to open" }, { GIMP_PDB_STRING, "url", "URL of a document to open" },
{ GIMP_PDB_INT32, "new_window", "Create a new window or use existing one?" }, { 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", gimp_install_procedure ("extension_web_browser",
"open URL in Netscape", "open URL in Netscape",
@ -141,7 +140,7 @@ query (void)
N_("<Toolbox>/Xtns/Web Browser/Open URL..."), N_("<Toolbox>/Xtns/Web Browser/Open URL..."),
NULL, NULL,
GIMP_EXTENSION, GIMP_EXTENSION,
nargs, 0, G_N_ELEMENTS (args), 0,
args, NULL); args, NULL);
} }

View File

@ -447,9 +447,6 @@ query (void)
{ {
{ GIMP_PDB_IMAGE, "image", "Output image" }, { 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[] = static GimpParamDef save_args[] =
{ {
@ -463,7 +460,6 @@ query (void)
{ GIMP_PDB_INT32, "optimize", "Optimization of entropy encoding parameters" }, { GIMP_PDB_INT32, "optimize", "Optimization of entropy encoding parameters" },
{ GIMP_PDB_INT32, "clr_transparent", "set all full-transparent pixels to 0" }, { 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 (); INIT_I18N ();
@ -476,7 +472,8 @@ query (void)
"<Load>/xjt", "<Load>/xjt",
NULL, NULL,
GIMP_PLUGIN, GIMP_PLUGIN,
nload_args, nload_return_vals, G_N_ELEMENTS (load_args),
G_N_ELEMENTS (load_return_vals),
load_args, load_return_vals); load_args, load_return_vals);
gimp_install_procedure ("file_xjt_save", gimp_install_procedure ("file_xjt_save",
@ -488,7 +485,7 @@ query (void)
"<Save>/xjt", "<Save>/xjt",
"RGB*, GRAY*", "RGB*, GRAY*",
GIMP_PLUGIN, GIMP_PLUGIN,
nsave_args, 0, G_N_ELEMENTS (save_args), 0,
save_args, NULL); save_args, NULL);
gimp_register_magic_load_handler ("file_xjt_load", gimp_register_magic_load_handler ("file_xjt_load",