Changeset: c945fb101f4b for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c945fb101f4b
Modified Files:
        gdk/gdk_utils.c
Branch: resource_management
Log Message:

doubling blk size maybe too aggressive


diffs (48 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -2283,9 +2283,8 @@ static void *
        if (sz > (sa->blk_size - sa->used)) {
                // out of space need new blk
                size_t nsize = SA_BLOCK_SIZE;
-               // double the size id needed
-               while (sz > nsize){
-                       nsize *= 2;
+               if (sz > nsize){
+                       nsize = sz;
                }
                if (sa->pa) {
                        r = (char*) _sa_alloc_internal(sa->pa, nsize);
@@ -2402,19 +2401,21 @@ sa_zalloc( allocator *sa, size_t sz )
 void
 sa_destroy( allocator *sa )
 {
-       bool root_allocator = sa->pa == NULL;
-       for (size_t i = 0; i < sa->nr; i++) {
-               char * next = sa->blks[i];
+       if (sa) {
+               bool root_allocator = sa->pa == NULL;
+               for (size_t i = 0; i < sa->nr; i++) {
+                       char * next = sa->blks[i];
+                       if (root_allocator) {
+                               GDKfree(next);
+                       } else {
+                               sa_free_blk(sa, next);
+                       }
+
+               }
                if (root_allocator) {
-                       GDKfree(next);
-               } else {
-                       sa_free_blk(sa, next);
+                       GDKfree(sa->blks);
+                       GDKfree(sa);
                }
-
-       }
-       if (root_allocator) {
-               GDKfree(sa->blks);
-               GDKfree(sa);
        }
 }
 
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to