Skip to contentSkip to conversation

perf tools: Free strlist in strlist__delete()

PATCH In review Namhyung Kim 2 participants 2 messages Sep 6, 2013 perf events

lore
Share & tools
lore

Namhyung Kim

author maintainer
#0 lore raw

PATCH 1/1 perf tools: Free strlist in strlist__delete()

From: Namhyung Kim <[email protected]>

It seems strlist never deleted after allocated. AFAICS every strlist is allocated dynamically, just free it in the _delete() function.

---
 tools/perf/util/strlist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/strlist.c +3 -1
index eabdce0a2daa..11593d899eb2 100644
@@ -155,8 +155,10 @@ out_error:
 
 void strlist__delete(struct strlist *slist)
 {
-	if (slist != NULL)
+	if (slist != NULL) {
 		rblist__delete(&slist->rblist);
+		free(slist);
+	}
 }
 
 struct str_node *strlist__entry(const struct strlist *slist, unsigned int idx)
Signature · 1 line
1.7.11.7
Acked-by on v1 1/1
#1 lore raw
Quoted 17 lines · Namhyung Kim

From: Namhyung Kim <[email protected]>

It seems strlist never deleted after allocated. AFAICS every strlist is allocated dynamically, just free it in the _delete() function.

---
  tools/perf/util/strlist.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/strlist.c +0 -0
index eabdce0a2daa..11593d899eb2 100644
@@ -155,8 +155,10 @@ out_error:
 

tools/perf/util/strlist.c out_error: · line 164

Quoted 10 lines
tools/perf/util/strlist.c +3 -1
  void strlist__delete(struct strlist *slist)
  {
-	if (slist != NULL)
+	if (slist != NULL) {
  		rblist__delete(&slist->rblist);
+		free(slist);
+	}
  }
 
  struct str_node *strlist__entry(const struct strlist *slist, unsigned int idx)

Yes, strlist__delete is the counterpart to strlist__new; the new function allocates the memory, so the delete should free it.