[sysprof/ftrace] Allocate name buffer on the stack



commit 1848d1fd05d9c82730996e763814c15f582743a7
Author: Søren Sandmann Pedersen <sandmann daimi au dk>
Date:   Sat Aug 15 05:01:34 2009 -0400

    Allocate name buffer on the stack

 process.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/process.c b/process.c
index d62cdb1..634de98 100644
--- a/process.c
+++ b/process.c
@@ -71,17 +71,15 @@ initialize (void)
 static Map *
 read_maps (int pid, int *n_maps)
 {
-    char *name = g_strdup_printf ("/proc/%d/maps", pid);
+    char name[256];
     char buffer[1024];
     FILE *in;
     GArray *result;
 
+    snprintf (name, sizeof (name), "/proc/%d/maps", pid);
     in = fopen (name, "r");
     if (!in)
-    {
-	g_free (name);
 	return NULL;
-    }
 
     result = g_array_new (FALSE, FALSE, sizeof (Map));
     
@@ -128,7 +126,6 @@ read_maps (int pid, int *n_maps)
 	}
     }
 
-    g_free (name);
     fclose (in);
 
     if (n_maps)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]