Commit e1eccf9a authored by antirez's avatar antirez
Browse files

zmalloc: Make fp var non local to fix build.

parent 945a2f94
...@@ -315,13 +315,14 @@ size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) { ...@@ -315,13 +315,14 @@ size_t zmalloc_get_smap_bytes_by_field(char *field, long pid) {
char line[1024]; char line[1024];
size_t bytes = 0; size_t bytes = 0;
int flen = strlen(field); int flen = strlen(field);
FILE *fp;
if (pid == -1) { if (pid == -1) {
FILE *fp = fopen("/proc/self/smaps","r"); fp = fopen("/proc/self/smaps","r");
} else { } else {
char filename[128]; char filename[128];
snprintf(filename,sizeof(filename),"/proc/%ld/smaps",pid); snprintf(filename,sizeof(filename),"/proc/%ld/smaps",pid);
FILE *fp = fopen(filename,"r"); fp = fopen(filename,"r");
} }
if (!fp) return 0; if (!fp) return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment