diff options
author | Hyeongsik Min <hyeongsik.min@samsung.com> | 2016-11-07 21:33:41 +0900 |
---|---|---|
committer | Hyeongsik Min <hyeongsik.min@samsung.com> | 2016-11-08 09:40:40 +0900 |
commit | 872b83ece7991deb0de0d6e85554a5880bde5540 (patch) | |
tree | 8849c562dc3312fbf9b865f74dbc4453fa272fd4 | |
parent | 6c7b7d54f013217213dc6672dd7bfa020167d45c (diff) | |
download | memps-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 |
Fix build warningssubmit/tizen_3.0_common/20161110.084657submit/tizen_3.0/20161109.042255submit/tizen_3.0.m2/20170104.093751submit/tizen/20161108.023400accepted/tizen/wearable/20161109.002332accepted/tizen/tv/20161109.002314accepted/tizen/mobile/20161109.002255accepted/tizen/ivi/20161109.002349accepted/tizen/common/20161108.131702accepted/tizen/3.0/wearable/20161110.021547accepted/tizen/3.0/tv/20161110.021532accepted/tizen/3.0/mobile/20161110.021512accepted/tizen/3.0/ivi/20161110.021610accepted/tizen/3.0/common/20161114.082327accepted/tizen/3.0.m2/wearable/20170104.142302accepted/tizen/3.0.m2/tv/20170104.142007accepted/tizen/3.0.m2/mobile/20170104.141400tizen_3.0_tvtizen_3.0.m2accepted/tizen_3.0.m2_wearableaccepted/tizen_3.0.m2_tvaccepted/tizen_3.0.m2_mobile
Change-Id: Icf8062b8f35b788a9d58ed2a7d207ef80a98bdaa
Signed-off-by: Hyeongsik Min <hyeongsik.min@samsung.com>
-rw-r--r-- | memps.c | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -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; } |