]> granicus.if.org Git - graphviz/commitdiff
a few less reallocs
authorellson <devnull@localhost>
Sun, 19 Jun 2005 12:14:23 +0000 (12:14 +0000)
committerellson <devnull@localhost>
Sun, 19 Jun 2005 12:14:23 +0000 (12:14 +0000)
lib/gvc/gvplugin.c

index cf5ef9db79d486a6c9afe3ea73f76eec88cb404e..6dc29293a3d68f010db1e2f5bd1129bdf05bb126 100644 (file)
@@ -106,13 +106,19 @@ gvplugin_library_t *gvplugin_library_load(char *path)
     char *s, *sym;
     int len;
     static char *p;
+    static int lenp;
 
     char *suffix = "_LTX_library";
 
-    p = realloc(p,strlen(libdir)
-                       + 1
-                       + strlen(path)
-                       + 1);
+    len = strlen(libdir) + 1 + strlen(path) + 1;
+    if (len > lenp) {
+       lenp = len+20;
+       if (p)
+           realloc(p, lenp);
+       else
+           p = malloc(lenp);
+    }
+       
     if (path[0] == '/') {
        strcpy(p, path);
     } else {