app/dialogs/tips-parser.c app/display/gimpdisplayshell-autoscroll.c
2007-05-23 Sven Neumann <sven@gimp.org> * app/dialogs/tips-parser.c * app/display/gimpdisplayshell-autoscroll.c * app/menus/plug-in-menus.c * app/plug-in/gimpenvirontable.c * app/plug-in/gimpinterpreterdb.c * app/plug-in/gimpplugindebug.c * app/plug-in/gimppluginshm.c * app/text/gimptextundo.c: allocate structs using GSlice * app/widgets/gimpselectiondata.c (gimp_selection_data_set_color): stack allocate tempory data. svn path=/trunk/; revision=22588
This commit is contained in:

committed by
Sven Neumann

parent
cd772f930a
commit
c7bffbceaa
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
2007-05-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/dialogs/tips-parser.c
|
||||
* app/display/gimpdisplayshell-autoscroll.c
|
||||
* app/menus/plug-in-menus.c
|
||||
* app/plug-in/gimpenvirontable.c
|
||||
* app/plug-in/gimpinterpreterdb.c
|
||||
* app/plug-in/gimpplugindebug.c
|
||||
* app/plug-in/gimppluginshm.c
|
||||
* app/text/gimptextundo.c: allocate structs using GSlice
|
||||
|
||||
* app/widgets/gimpselectiondata.c (gimp_selection_data_set_color):
|
||||
stack allocate tempory data.
|
||||
|
||||
2007-05-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimppalette-import.c
|
||||
|
@ -50,8 +50,7 @@ typedef enum
|
||||
TIPS_LOCALE_MISMATCH
|
||||
} TipsParserLocaleState;
|
||||
|
||||
typedef struct _TipsParser TipsParser;
|
||||
struct _TipsParser
|
||||
typedef struct
|
||||
{
|
||||
TipsParserState state;
|
||||
TipsParserState last_known_state;
|
||||
@ -60,10 +59,9 @@ struct _TipsParser
|
||||
gint markup_depth;
|
||||
gint unknown_depth;
|
||||
GString *value;
|
||||
|
||||
GimpTip *current_tip;
|
||||
GList *tips;
|
||||
};
|
||||
} TipsParser;
|
||||
|
||||
|
||||
static void tips_parser_start_element (GMarkupParseContext *context,
|
||||
@ -114,7 +112,7 @@ gimp_tip_new (const gchar *format,
|
||||
|
||||
g_return_val_if_fail (format != NULL, NULL);
|
||||
|
||||
tip = g_new0 (GimpTip, 1);
|
||||
tip = g_slice_new0 (GimpTip);
|
||||
|
||||
va_start (args, format);
|
||||
|
||||
@ -151,7 +149,8 @@ gimp_tip_free (GimpTip *tip)
|
||||
|
||||
g_free (tip->welcome);
|
||||
g_free (tip->thetip);
|
||||
g_free (tip);
|
||||
|
||||
g_slice_free (GimpTip, tip);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,15 +172,14 @@ gimp_tips_from_file (const gchar *filename,
|
||||
GError **error)
|
||||
{
|
||||
GimpXmlParser *xml_parser;
|
||||
TipsParser *parser;
|
||||
TipsParser parser = { 0, };
|
||||
const gchar *tips_locale;
|
||||
GList *tips = NULL;
|
||||
GList *tips = NULL;
|
||||
|
||||
g_return_val_if_fail (filename != NULL, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
parser = g_new0 (TipsParser, 1);
|
||||
parser->value = g_string_new (NULL);
|
||||
parser.value = g_string_new (NULL);
|
||||
|
||||
/* This is a special string to specify the language identifier to
|
||||
look for in the gimp-tips.xml file. Please translate the C in it
|
||||
@ -195,22 +193,23 @@ gimp_tips_from_file (const gchar *filename,
|
||||
tips_locale += strlen ("tips-locale:");
|
||||
|
||||
if (*tips_locale && *tips_locale != 'C')
|
||||
parser->locale = tips_locale;
|
||||
parser.locale = tips_locale;
|
||||
}
|
||||
else
|
||||
g_warning ("Wrong translation for 'tips-locale:', fix the translation!");
|
||||
{
|
||||
g_warning ("Wrong translation for 'tips-locale:', fix the translation!");
|
||||
}
|
||||
|
||||
xml_parser = gimp_xml_parser_new (&markup_parser, parser);
|
||||
xml_parser = gimp_xml_parser_new (&markup_parser, &parser);
|
||||
|
||||
gimp_xml_parser_parse_file (xml_parser, filename, error);
|
||||
|
||||
gimp_xml_parser_free (xml_parser);
|
||||
|
||||
tips = g_list_reverse (parser->tips);
|
||||
tips = g_list_reverse (parser.tips);
|
||||
|
||||
gimp_tip_free (parser->current_tip);
|
||||
g_string_free (parser->value, TRUE);
|
||||
g_free (parser);
|
||||
gimp_tip_free (parser.current_tip);
|
||||
g_string_free (parser.value, TRUE);
|
||||
|
||||
return tips;
|
||||
}
|
||||
@ -234,7 +233,7 @@ tips_parser_start_element (GMarkupParseContext *context,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
TipsParser *parser = (TipsParser *) user_data;
|
||||
TipsParser *parser = user_data;
|
||||
|
||||
switch (parser->state)
|
||||
{
|
||||
@ -249,7 +248,7 @@ tips_parser_start_element (GMarkupParseContext *context,
|
||||
if (strcmp (element_name, "tip") == 0)
|
||||
{
|
||||
parser->state = TIPS_IN_TIP;
|
||||
parser->current_tip = g_new0 (GimpTip, 1);
|
||||
parser->current_tip = g_slice_new0 (GimpTip);
|
||||
}
|
||||
else
|
||||
tips_parser_start_unknown (parser);
|
||||
@ -292,7 +291,7 @@ tips_parser_end_element (GMarkupParseContext *context,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
TipsParser *parser = (TipsParser *) user_data;
|
||||
TipsParser *parser = user_data;
|
||||
|
||||
switch (parser->state)
|
||||
{
|
||||
@ -345,7 +344,7 @@ tips_parser_characters (GMarkupParseContext *context,
|
||||
gpointer user_data,
|
||||
GError **error)
|
||||
{
|
||||
TipsParser *parser = (TipsParser *) user_data;
|
||||
TipsParser *parser = user_data;
|
||||
|
||||
switch (parser->state)
|
||||
{
|
||||
@ -360,10 +359,14 @@ tips_parser_characters (GMarkupParseContext *context,
|
||||
{
|
||||
if (text[i] != ' ' &&
|
||||
text[i] != '\t' && text[i] != '\n' && text[i] != '\r')
|
||||
g_string_append_c (parser->value, text[i]);
|
||||
{
|
||||
g_string_append_c (parser->value, text[i]);
|
||||
}
|
||||
else if (parser->value->len > 0 &&
|
||||
parser->value->str[parser->value->len - 1] != ' ')
|
||||
g_string_append_c (parser->value, ' ');
|
||||
{
|
||||
g_string_append_c (parser->value, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -70,7 +70,7 @@ gimp_display_shell_autoscroll_start (GimpDisplayShell *shell,
|
||||
if (shell->scroll_info)
|
||||
return;
|
||||
|
||||
info = g_new0 (ScrollInfo, 1);
|
||||
info = g_slice_new0 (ScrollInfo);
|
||||
|
||||
info->mevent = mevent;
|
||||
info->device = mevent->device;
|
||||
@ -101,7 +101,7 @@ gimp_display_shell_autoscroll_stop (GimpDisplayShell *shell)
|
||||
info->timeout_id = 0;
|
||||
}
|
||||
|
||||
g_free (info);
|
||||
g_slice_free (ScrollInfo, info);
|
||||
shell->scroll_info = NULL;
|
||||
}
|
||||
|
||||
@ -167,7 +167,7 @@ gimp_display_shell_autoscroll_timeout (gpointer data)
|
||||
}
|
||||
else
|
||||
{
|
||||
g_free (info);
|
||||
g_slice_free (ScrollInfo, info);
|
||||
shell->scroll_info = NULL;
|
||||
|
||||
return FALSE;
|
||||
|
@ -65,7 +65,7 @@ static void plug_in_menus_add_proc (GimpUIManager *manager,
|
||||
const gchar *ui_path,
|
||||
GimpPlugInProcedure *proc,
|
||||
const gchar *menu_path);
|
||||
static void plug_in_menus_tree_insert (GTree *entries,
|
||||
static void plug_in_menus_tree_insert (GTree *entries,
|
||||
const gchar * path,
|
||||
PlugInMenuEntry *entry);
|
||||
static gboolean plug_in_menus_tree_traverse (gpointer key,
|
||||
@ -76,6 +76,7 @@ static gchar * plug_in_menus_build_path (GimpUIManager *manager,
|
||||
guint merge_id,
|
||||
const gchar *menu_path,
|
||||
gboolean for_menu);
|
||||
static void plug_in_menu_entry_free (PlugInMenuEntry *entry);
|
||||
|
||||
|
||||
/* public functions */
|
||||
@ -116,7 +117,8 @@ plug_in_menus_setup (GimpUIManager *manager,
|
||||
}
|
||||
|
||||
menu_entries = g_tree_new_full ((GCompareDataFunc) strcmp, NULL,
|
||||
g_free, g_free);
|
||||
g_free,
|
||||
(GDestroyNotify) plug_in_menu_entry_free);
|
||||
|
||||
for (list = plug_in_manager->plug_in_procedures;
|
||||
list;
|
||||
@ -140,7 +142,7 @@ plug_in_menus_setup (GimpUIManager *manager,
|
||||
{
|
||||
if (g_str_has_prefix (path->data, manager->name))
|
||||
{
|
||||
PlugInMenuEntry *entry = g_new0 (PlugInMenuEntry, 1);
|
||||
PlugInMenuEntry *entry = g_slice_new0 (PlugInMenuEntry);
|
||||
const gchar *progname;
|
||||
const gchar *locale_domain;
|
||||
|
||||
@ -564,3 +566,9 @@ plug_in_menus_build_path (GimpUIManager *manager,
|
||||
|
||||
return action_path;
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_menu_entry_free (PlugInMenuEntry *entry)
|
||||
{
|
||||
g_slice_free (PlugInMenuEntry, entry);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ static void gimp_environ_table_clear_vars (GimpEnvironTable *enviro
|
||||
static void gimp_environ_table_clear_internal (GimpEnvironTable *environ_table);
|
||||
static void gimp_environ_table_clear_envp (GimpEnvironTable *environ_table);
|
||||
|
||||
static void gimp_environ_table_free_value (gpointer value);
|
||||
static void gimp_environ_table_free_value (GimpEnvironValue *val);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpEnvironTable, gimp_environ_table, G_TYPE_OBJECT)
|
||||
@ -148,7 +148,8 @@ gimp_environ_table_load (GimpEnvironTable *environ_table,
|
||||
environ_table->vars =
|
||||
g_hash_table_new_full (gimp_environ_table_str_hash,
|
||||
gimp_environ_table_str_equal,
|
||||
g_free, gimp_environ_table_free_value);
|
||||
g_free,
|
||||
(GDestroyNotify) gimp_environ_table_free_value);
|
||||
|
||||
gimp_datafiles_read_directories (env_path,
|
||||
G_FILE_TEST_EXISTS,
|
||||
@ -173,8 +174,9 @@ gimp_environ_table_add (GimpEnvironTable *environ_table,
|
||||
g_hash_table_new_full (g_str_hash, g_str_equal,
|
||||
g_free, gimp_environ_table_free_value);
|
||||
|
||||
val = g_new (GimpEnvironValue, 1);
|
||||
val->value = g_strdup (value);
|
||||
val = g_slice_new (GimpEnvironValue);
|
||||
|
||||
val->value = g_strdup (value);
|
||||
val->separator = g_strdup (separator);
|
||||
|
||||
g_hash_table_insert (environ_table->internal, g_strdup (name), val);
|
||||
@ -301,7 +303,7 @@ gimp_environ_table_load_env_file (const GimpDatafileData *file_data,
|
||||
|
||||
if (! g_hash_table_lookup (environ_table->vars, name))
|
||||
{
|
||||
val = g_new (GimpEnvironValue, 1);
|
||||
val = g_slice_new (GimpEnvironValue);
|
||||
|
||||
val->value = gimp_config_path_expand (value, FALSE, NULL);
|
||||
val->separator = g_strdup (separator);
|
||||
@ -447,11 +449,10 @@ gimp_environ_table_clear_envp (GimpEnvironTable *environ_table)
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_environ_table_free_value (gpointer value)
|
||||
gimp_environ_table_free_value (GimpEnvironValue *val)
|
||||
{
|
||||
GimpEnvironValue *val = value;
|
||||
|
||||
g_free (val->value);
|
||||
g_free (val->separator);
|
||||
g_free (val);
|
||||
|
||||
g_slice_free (GimpEnvironValue, val);
|
||||
}
|
||||
|
@ -246,7 +246,9 @@ gimp_interpreter_db_add_program (GimpInterpreterDB *db,
|
||||
const GimpDatafileData *file_data,
|
||||
gchar *buffer)
|
||||
{
|
||||
gchar *name, *program, *p;
|
||||
gchar *name;
|
||||
gchar *program;
|
||||
gchar *p;
|
||||
|
||||
p = strchr (buffer, '=');
|
||||
if (! p)
|
||||
@ -328,29 +330,28 @@ static gboolean
|
||||
gimp_interpreter_db_add_extension (GimpInterpreterDB *db,
|
||||
gchar **tokens)
|
||||
{
|
||||
gchar *name, *extension, *program;
|
||||
|
||||
name = tokens[0];
|
||||
extension = tokens[3];
|
||||
program = tokens[5];
|
||||
const gchar *name = tokens[0];
|
||||
const gchar *extension = tokens[3];
|
||||
const gchar *program = tokens[5];
|
||||
|
||||
if (! g_hash_table_lookup (db->extension_names, name))
|
||||
{
|
||||
gchar *prog;
|
||||
|
||||
if (extension[0] == '\0' || extension[0] == '/')
|
||||
return FALSE;
|
||||
|
||||
program = g_strdup (program);
|
||||
prog = g_strdup (program);
|
||||
|
||||
g_hash_table_insert (db->extensions, g_strdup (extension), program);
|
||||
|
||||
g_hash_table_insert (db->extension_names, g_strdup (name), program);
|
||||
g_hash_table_insert (db->extensions, g_strdup (extension), prog);
|
||||
g_hash_table_insert (db->extension_names, g_strdup (name), prog);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
scanarg (gchar *s)
|
||||
scanarg (const gchar *s)
|
||||
{
|
||||
gchar c;
|
||||
|
||||
@ -374,7 +375,9 @@ scanarg (gchar *s)
|
||||
static guint
|
||||
unquote (gchar *from)
|
||||
{
|
||||
gchar c, *s = from, *p = from;
|
||||
gchar *s = from;
|
||||
gchar *p = from;
|
||||
gchar c;
|
||||
|
||||
while ((c = *s++) != '\0')
|
||||
{
|
||||
@ -420,7 +423,9 @@ gimp_interpreter_db_add_magic (GimpInterpreterDB *db,
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
offset = 0;
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
if (! scanarg (magic))
|
||||
return FALSE;
|
||||
@ -438,7 +443,7 @@ gimp_interpreter_db_add_magic (GimpInterpreterDB *db,
|
||||
else if (unquote (mask) != size)
|
||||
return FALSE;
|
||||
|
||||
interp_magic = g_new (GimpInterpreterMagic, 1);
|
||||
interp_magic = g_slice_new (GimpInterpreterMagic);
|
||||
|
||||
interp_magic->offset = offset;
|
||||
interp_magic->magic = g_memdup (magic, size);
|
||||
@ -470,7 +475,8 @@ gimp_interpreter_db_clear_magics (GimpInterpreterDB *db)
|
||||
g_free (magic->magic);
|
||||
g_free (magic->mask);
|
||||
g_free (magic->program);
|
||||
g_free (magic);
|
||||
|
||||
g_slice_free (GimpInterpreterMagic, magic);
|
||||
|
||||
last = list;
|
||||
list = list->next;
|
||||
@ -531,16 +537,15 @@ resolve_program (gpointer key,
|
||||
static void
|
||||
gimp_interpreter_db_resolve_programs (GimpInterpreterDB *db)
|
||||
{
|
||||
GSList *list;
|
||||
gchar *program;
|
||||
GimpInterpreterMagic *magic;
|
||||
GHashTable *extensions;
|
||||
GSList *list;
|
||||
GHashTable *extensions;
|
||||
|
||||
list = db->magics;
|
||||
|
||||
while (list)
|
||||
for (list = db->magics; list; list = list->next)
|
||||
{
|
||||
magic = list->data;
|
||||
GimpInterpreterMagic *magic = list->data;
|
||||
const gchar *program;
|
||||
|
||||
program = g_hash_table_lookup (db->programs, magic->program);
|
||||
|
||||
@ -549,8 +554,6 @@ gimp_interpreter_db_resolve_programs (GimpInterpreterDB *db)
|
||||
g_free (magic->program);
|
||||
magic->program = g_strdup (program);
|
||||
}
|
||||
|
||||
list = list->next;
|
||||
}
|
||||
|
||||
extensions = db->extensions;
|
||||
@ -620,7 +623,9 @@ resolve_sh_bang (GimpInterpreterDB *db,
|
||||
gssize len,
|
||||
gchar **interp_arg)
|
||||
{
|
||||
gchar *cp, *name, *program;
|
||||
gchar *cp;
|
||||
gchar *name;
|
||||
gchar *program;
|
||||
|
||||
cp = strchr (buffer, '\n');
|
||||
if (! cp)
|
||||
|
@ -69,7 +69,7 @@ gimp_plug_in_debug_new (void)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
debug = g_new (GimpPlugInDebug, 1);
|
||||
debug = g_slice_new (GimpPlugInDebug);
|
||||
|
||||
debug->args = args;
|
||||
|
||||
@ -102,7 +102,7 @@ gimp_plug_in_debug_free (GimpPlugInDebug *debug)
|
||||
if (debug->args)
|
||||
g_strfreev (debug->args);
|
||||
|
||||
g_free (debug);
|
||||
g_slice_free (GimpPlugInDebug, debug);
|
||||
}
|
||||
|
||||
gchar **
|
||||
|
@ -93,7 +93,7 @@ gimp_plug_in_shm_new (void)
|
||||
* we'll fall back on sending the data over the pipe.
|
||||
*/
|
||||
|
||||
GimpPlugInShm *shm = g_new0 (GimpPlugInShm, 1);
|
||||
GimpPlugInShm *shm = g_slice_new0 (GimpPlugInShm);
|
||||
|
||||
shm->shm_ID = -1;
|
||||
|
||||
@ -231,7 +231,7 @@ gimp_plug_in_shm_new (void)
|
||||
|
||||
if (shm->shm_ID == -1)
|
||||
{
|
||||
g_free (shm);
|
||||
g_slice_free (GimpPlugInShm, shm);
|
||||
shm = NULL;
|
||||
}
|
||||
|
||||
@ -275,7 +275,7 @@ gimp_plug_in_shm_free (GimpPlugInShm *shm)
|
||||
|
||||
}
|
||||
|
||||
g_free (shm);
|
||||
g_slice_free (GimpPlugInShm, shm);
|
||||
}
|
||||
|
||||
gint
|
||||
|
@ -119,7 +119,7 @@ gimp_text_undo_constructor (GType type,
|
||||
{
|
||||
g_assert (text_undo->pspec->owner_type == GIMP_TYPE_TEXT);
|
||||
|
||||
text_undo->value = g_new0 (GValue, 1);
|
||||
text_undo->value = g_slice_new0 (GValue);
|
||||
|
||||
g_value_init (text_undo->value, text_undo->pspec->value_type);
|
||||
g_object_get_property (G_OBJECT (layer->text),
|
||||
@ -218,7 +218,7 @@ gimp_text_undo_pop (GimpUndo *undo,
|
||||
|
||||
g_return_if_fail (layer->text != NULL);
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
value = g_slice_new0 (GValue);
|
||||
g_value_init (value, text_undo->pspec->value_type);
|
||||
|
||||
g_object_get_property (G_OBJECT (layer->text),
|
||||
@ -228,7 +228,7 @@ gimp_text_undo_pop (GimpUndo *undo,
|
||||
text_undo->pspec->name, text_undo->value);
|
||||
|
||||
g_value_unset (text_undo->value);
|
||||
g_free (text_undo->value);
|
||||
g_slice_free (GValue, text_undo->value);
|
||||
|
||||
text_undo->value = value;
|
||||
}
|
||||
@ -290,7 +290,7 @@ gimp_text_undo_free (GimpUndo *undo,
|
||||
if (text_undo->pspec)
|
||||
{
|
||||
g_value_unset (text_undo->value);
|
||||
g_free (text_undo->value);
|
||||
g_slice_free (GValue, text_undo->value);
|
||||
|
||||
text_undo->value = NULL;
|
||||
text_undo->pspec = NULL;
|
||||
|
@ -291,14 +291,12 @@ void
|
||||
gimp_selection_data_set_color (GtkSelectionData *selection,
|
||||
const GimpRGB *color)
|
||||
{
|
||||
guint16 *vals;
|
||||
guint16 vals[4];
|
||||
guchar r, g, b, a;
|
||||
|
||||
g_return_if_fail (selection != NULL);
|
||||
g_return_if_fail (color != NULL);
|
||||
|
||||
vals = g_new (guint16, 4);
|
||||
|
||||
gimp_rgba_get_uchar (color, &r, &g, &b, &a);
|
||||
|
||||
vals[0] = r + (r << 8);
|
||||
@ -307,9 +305,7 @@ gimp_selection_data_set_color (GtkSelectionData *selection,
|
||||
vals[3] = a + (a << 8);
|
||||
|
||||
gtk_selection_data_set (selection, selection->target,
|
||||
16, (guchar *) vals, 8);
|
||||
|
||||
g_free (vals);
|
||||
16, (const guchar *) vals, 8);
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
Reference in New Issue
Block a user