summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyeongsik Min <hyeongsik.min@samsung.com>2016-11-07 21:33:41 +0900
committerHyeongsik Min <hyeongsik.min@samsung.com>2016-11-08 09:40:40 +0900
commit872b83ece7991deb0de0d6e85554a5880bde5540 (patch)
tree8849c562dc3312fbf9b865f74dbc4453fa272fd4
parent6c7b7d54f013217213dc6672dd7bfa020167d45c (diff)
downloadmemps-accepted/tizen_3.0.m2_tv.tar.gz
memps-accepted/tizen_3.0.m2_tv.tar.bz2
memps-accepted/tizen_3.0.m2_tv.zip
Change-Id: Icf8062b8f35b788a9d58ed2a7d207ef80a98bdaa Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
-rw-r--r--memps.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/memps.c b/memps.c
index 84f4f06..deee6d3 100644
--- a/memps.c
+++ b/memps.c
@@ -78,8 +78,8 @@ struct mapinfo {
unsigned shared_dirty;
unsigned private_clean;
unsigned private_dirty;
- char perm[4];
- char name[1];
+ char *perm;
+ char *name;
};
/* classify normal, graphic and other devices memory */
@@ -333,15 +333,15 @@ mapinfo *read_mapinfo(char** smaps, int line_cnt)
if (len < 1)
return 0;
- mi = malloc(sizeof(mapinfo) + len + 16);
+ mi = malloc(sizeof(mapinfo));
if (mi == 0)
return 0;
- n = sscanf(line, "%lx-%lx %s %*s %*s %*s %[^\n]",
+ n = sscanf(line, "%lx-%lx %ms %*s %*s %*s %m[^\n]",
&mi->start, &mi->end, &mi->perm, &mi->name);
- if (n == 3)
- strncpy(mi->name, "[anon]", strlen("[anon]")+1);
+ if (n == 3 && !mi->name)
+ mi->name = strndup("[anon]", strlen("[anon]"));
while (line_cnt-- && (line = cgets(smaps))) {
if (sscanf(line, "Size: %d kB", &mi->size) == 1) {}
@@ -355,10 +355,6 @@ mapinfo *read_mapinfo(char** smaps, int line_cnt)
}
return mi;
- oops:
- printf("mi get error\n");
- free(mi);
- return 0;
}
static unsigned total_gem_memory(void)
@@ -674,12 +670,10 @@ mapinfo *load_maps(int pid)
milist->private_clean += mi->private_clean;
milist->private_dirty += mi->private_dirty;
- milist->perm[0] = mi->perm[0];
- milist->perm[1] = mi->perm[1];
- milist->perm[2] = mi->perm[2];
- milist->perm[3] = mi->perm[3];
milist->end = mi->end;
strncpy(milist->perm, mi->perm, 4);
+ free(mi->perm);
+ free(mi->name);
free(mi);
continue;
}
@@ -762,6 +756,8 @@ get_trib_mapinfo(unsigned int tgid, mapinfo *milist,
temp = mi;
mi = mi->next;
+ free(temp->perm);
+ free(temp->name);
free(temp);
temp = NULL;
}