Looking through lib/fusion/vector.c it seems like there's a memory
leak in ensure_capacity() when the vector has to grow. Am I missing
something, or would something like the following patch be appropriate?

/TomB

--- DirectFB-0.9.21.orig/lib/fusion/vector.c    2004-08-04 09:58:18.000000000 -0700
+++ DirectFB-0.9.21/lib/fusion/vector.c 2004-10-09 21:45:06.000000000 -0700
@@ -47,6 +47,7 @@
      }
      else if (vector->count == vector->capacity) {
           void *elements;
+          void *oldelements = vector->elements;
           int   capacity = vector->capacity << 1;
 
           elements = SHMALLOC( capacity * sizeof(void*) );
@@ -58,6 +59,8 @@
 
           vector->elements = elements;
           vector->capacity = capacity;
+
+          SHFREE( oldelements );
      }
 
      return true;


Reply via email to