This is an automated email from Gerrit.

Paul Fertser ([email protected]) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2028

-- gerrit

commit 53e7ca816e5082f52932f5b459144fdf14f802c0
Author: Paul Fertser <[email protected]>
Date:   Fri Mar 7 10:45:31 2014 +0400

    gdb_server: do not copy feature names for tdesc generation
    
    We always have feature names defined by string literals and the
    standard guarantees static storage duration for them. Hence, there's
    no need duplicating and then freeing them.
    
    Valgrind-tested.
    
    Change-Id: I1b77f966c548e3694141c63bd8680735f0f47505
    Signed-off-by: Paul Fertser <[email protected]>

diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c
index f2d0a46..2912c74 100644
--- a/src/server/gdb_server.c
+++ b/src/server/gdb_server.c
@@ -1998,7 +1998,7 @@ static int gdb_generate_reg_type_description(struct 
target *target,
 /* Get a list of available target registers features. feature_list must
  * be freed by caller.
  */
-static int get_reg_features_list(struct target *target, char **feature_list[], 
int *feature_list_size,
+static int get_reg_features_list(struct target *target, char const 
**feature_list[], int *feature_list_size,
                struct reg **reg_list, int reg_list_size)
 {
        int tbl_sz = 0;
@@ -2019,7 +2019,7 @@ static int get_reg_features_list(struct target *target, 
char **feature_list[], i
                         */
                        for (int j = 0; j < (tbl_sz + 1); j++) {
                                if (!((*feature_list)[j])) {
-                                       (*feature_list)[tbl_sz++] = 
strdup(reg_list[i]->feature->name);
+                                       (*feature_list)[tbl_sz++] = 
reg_list[i]->feature->name;
                                        *feature_list = realloc(*feature_list, 
sizeof(char *) * (tbl_sz + 1));
                                        (*feature_list)[tbl_sz] = NULL;
                                        break;
@@ -2042,7 +2042,7 @@ static int gdb_generate_target_description(struct target 
*target, char **tdesc_o
        int retval = ERROR_OK;
        struct reg **reg_list = NULL;
        int reg_list_size;
-       char **features = NULL;
+       char const **features = NULL;
        int feature_list_size = 0;
        char *tdesc = NULL;
        int pos = 0;
@@ -2149,10 +2149,6 @@ static int gdb_generate_target_description(struct target 
*target, char **tdesc_o
                        "</target>\n");
 
 error:
-
-       /* note: features[] contains (feature_list_size + 1) elements */
-       for (int j = feature_list_size; j >= 0; j--)
-               free(features[j]);
        free(features);
        free(reg_list);
 
@@ -2223,7 +2219,7 @@ static int gdb_target_description_supported(struct target 
*target, int *supporte
        int retval = ERROR_OK;
        struct reg **reg_list = NULL;
        int reg_list_size = 0;
-       char **features = NULL;
+       char const **features = NULL;
        int feature_list_size = 0;
 
        retval = target_get_gdb_reg_list(target, &reg_list,
@@ -2254,10 +2250,6 @@ static int gdb_target_description_supported(struct 
target *target, int *supporte
        }
 
 error:
-
-       /* note: features[] contains (feature_list_size + 1) elements */
-       for (int j = feature_list_size; j >= 0; j--)
-               free(features[j]);
        free(features);
 
        free(reg_list);

-- 

------------------------------------------------------------------------------
Subversion Kills Productivity. Get off Subversion & Make the Move to Perforce.
With Perforce, you get hassle-free workflows. Merge that actually works. 
Faster operations. Version large binaries.  Built-in WAN optimization and the
freedom to use Git, Perforce or both. Make the move to Perforce.
http://pubads.g.doubleclick.net/gampad/clk?id=122218951&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to