Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 07 Feb 2016 15:47:21 UTC Commit: f9149ccd4ad1fb0271d3d4de9fd985a8f801b7a4 https://github.com/geany/geany-plugins/commit/f9149ccd4ad1fb0271d3d4de9fd985...
Log Message: ----------- debugger/gdb_mi: Slightly reduce memory usage
Modified Paths: -------------- debugger/src/dbm_gdb.c debugger/src/gdb_mi.c debugger/src/gdb_mi.h
Modified: debugger/src/dbm_gdb.c 28 lines changed, 14 insertions(+), 14 deletions(-) =================================================================== @@ -927,8 +927,8 @@ static int get_break_number(char* file, int line) body = gdb_mi_result_var(table, "body", GDB_MI_VAL_LIST); gdb_mi_result_foreach_matched (bkpt, body, "bkpt", GDB_MI_VAL_LIST) { - const gchar *number = gdb_mi_result_var(bkpt->val->list, "number", GDB_MI_VAL_STRING); - const gchar *location = gdb_mi_result_var(bkpt->val->list, "original-location", GDB_MI_VAL_STRING); + const gchar *number = gdb_mi_result_var(bkpt->val->v.list, "number", GDB_MI_VAL_STRING); + const gchar *location = gdb_mi_result_var(bkpt->val->v.list, "original-location", GDB_MI_VAL_STRING); const gchar *colon; gboolean break_found = FALSE;
@@ -1091,9 +1091,9 @@ static GList* get_stack(void) stack_node = gdb_mi_result_var(record->first, "stack", GDB_MI_VAL_LIST); gdb_mi_result_foreach_matched (frame_node, stack_node, "frame", GDB_MI_VAL_LIST) { - const gchar *addr = gdb_mi_result_var(frame_node->val->list, "addr", GDB_MI_VAL_STRING); - const gchar *func = gdb_mi_result_var(frame_node->val->list, "func", GDB_MI_VAL_STRING); - const gchar *line = gdb_mi_result_var(frame_node->val->list, "line", GDB_MI_VAL_STRING); + const gchar *addr = gdb_mi_result_var(frame_node->val->v.list, "addr", GDB_MI_VAL_STRING); + const gchar *func = gdb_mi_result_var(frame_node->val->v.list, "func", GDB_MI_VAL_STRING); + const gchar *line = gdb_mi_result_var(frame_node->val->v.list, "line", GDB_MI_VAL_STRING); const gchar *file, *fullname; frame *f = frame_new();
@@ -1101,9 +1101,9 @@ static GList* get_stack(void) f->function = g_strdup(func);
/* file: fullname | file | from */ - if ((fullname = file = gdb_mi_result_var(frame_node->val->list, "fullname", GDB_MI_VAL_STRING)) || - (file = gdb_mi_result_var(frame_node->val->list, "file", GDB_MI_VAL_STRING)) || - (file = gdb_mi_result_var(frame_node->val->list, "from", GDB_MI_VAL_STRING))) + if ((fullname = file = gdb_mi_result_var(frame_node->val->v.list, "fullname", GDB_MI_VAL_STRING)) || + (file = gdb_mi_result_var(frame_node->val->v.list, "file", GDB_MI_VAL_STRING)) || + (file = gdb_mi_result_var(frame_node->val->v.list, "from", GDB_MI_VAL_STRING))) { f->file = g_strdup(file); } @@ -1213,7 +1213,7 @@ static void update_files(void) files_node = gdb_mi_result_var(record->first, "files", GDB_MI_VAL_LIST); gdb_mi_result_foreach_matched (files_node, files_node, NULL, GDB_MI_VAL_LIST) { - const gchar *fullname = gdb_mi_result_var(files_node->val->list, "fullname", GDB_MI_VAL_STRING); + const gchar *fullname = gdb_mi_result_var(files_node->val->v.list, "fullname", GDB_MI_VAL_STRING);
if (fullname && !g_hash_table_lookup(ht, fullname)) { @@ -1325,11 +1325,11 @@ static void update_autos(void)
gdb_mi_result_foreach_matched (stack_args, stack_args, "frame", GDB_MI_VAL_LIST) { - const struct gdb_mi_result *args = gdb_mi_result_var(stack_args->val->list, "args", GDB_MI_VAL_LIST); + const struct gdb_mi_result *args = gdb_mi_result_var(stack_args->val->v.list, "args", GDB_MI_VAL_LIST);
gdb_mi_result_foreach_matched (args, args, "name", GDB_MI_VAL_STRING) { - variable *var = variable_new(args->val->string, VT_ARGUMENT); + variable *var = variable_new(args->val->v.string, VT_ARGUMENT); vars = g_list_append(vars, var); } } @@ -1342,7 +1342,7 @@ static void update_autos(void)
gdb_mi_result_foreach_matched (locals, locals, "name", GDB_MI_VAL_STRING) { - variable *var = variable_new(locals->val->string, VT_LOCAL); + variable *var = variable_new(locals->val->v.string, VT_LOCAL); vars = g_list_append(vars, var); } } @@ -1445,8 +1445,8 @@ static GList* get_children (gchar* path)
gdb_mi_result_foreach_matched (child_node, child_node, "child", GDB_MI_VAL_LIST) { - const gchar *internal = gdb_mi_result_var(child_node->val->list, "name", GDB_MI_VAL_STRING); - const gchar *name = gdb_mi_result_var(child_node->val->list, "exp", GDB_MI_VAL_STRING); + const gchar *internal = gdb_mi_result_var(child_node->val->v.list, "name", GDB_MI_VAL_STRING); + const gchar *name = gdb_mi_result_var(child_node->val->v.list, "exp", GDB_MI_VAL_STRING); variable *var;
if (! name || ! internal)
Modified: debugger/src/gdb_mi.c 20 lines changed, 9 insertions(+), 11 deletions(-) =================================================================== @@ -47,13 +47,11 @@ void gdb_mi_value_free(struct gdb_mi_value *val) switch (val->type) { case GDB_MI_VAL_STRING: - g_free(val->string); - g_warn_if_fail(val->list == NULL); + g_free(val->v.string); break;
case GDB_MI_VAL_LIST: - gdb_mi_result_free(val->list, TRUE); - g_warn_if_fail(val->string == NULL); + gdb_mi_result_free(val->v.list, TRUE); break; } g_free(val); @@ -216,7 +214,7 @@ static struct gdb_mi_value *parse_value(const gchar **p) { val = g_malloc0(sizeof *val); val->type = GDB_MI_VAL_STRING; - val->string = parse_cstring(p); + val->v.string = parse_cstring(p); } else if (**p == '{' || **p == '[') { @@ -235,7 +233,7 @@ static struct gdb_mi_value *parse_value(const gchar **p) if (prev) prev->next = item; else - val->list = item; + val->v.list = item; prev = item; } else @@ -396,9 +394,9 @@ const void *gdb_mi_result_var(const struct gdb_mi_result *result, const gchar *n if (! val || val->type != type) return NULL; else if (val->type == GDB_MI_VAL_STRING) - return val->string; + return val->v.string; else if (val->type == GDB_MI_VAL_LIST) - return val->list; + return val->v.list; return NULL; }
@@ -452,12 +450,12 @@ static void gdb_mi_value_dump(const struct gdb_mi_value *v, gint indent) switch (v->type) { case GDB_MI_VAL_STRING: - fprintf(stderr, "%*sstring = %s\n", indent * 2, "", v->string); + fprintf(stderr, "%*sstring = %s\n", indent * 2, "", v->v.string); break; case GDB_MI_VAL_LIST: fprintf(stderr, "%*slist =>\n", indent * 2, ""); - if (v->list) - gdb_mi_result_dump(v->list, TRUE, indent + 1); + if (v->v.list) + gdb_mi_result_dump(v->v.list, TRUE, indent + 1); break; } }
Modified: debugger/src/gdb_mi.h 6 lines changed, 4 insertions(+), 2 deletions(-) =================================================================== @@ -34,8 +34,10 @@ struct gdb_mi_result; struct gdb_mi_value { enum gdb_mi_value_type type; - gchar *string; - struct gdb_mi_result *list; + union { + gchar *string; + struct gdb_mi_result *list; + } v; };
struct gdb_mi_result
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org