diff mbox

libgo patch committed: Don't explicitly free tiny blocks

Message ID mcrk37v2618.fsf@iant-glaptop.roam.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor July 2, 2014, 2:23 p.m. UTC
This patch fixes libgo to not explicitly free tiny blocks when deleting
an entry from a map.  The memory allocator now has a special case for
tiny objects (less than 16 bytes), and they can not be explicitly freed,
only garbage collected.  This is PR go/61620.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r a45b1aa17901 libgo/runtime/go-map-delete.c
--- a/libgo/runtime/go-map-delete.c	Tue Jul 01 16:18:58 2014 -0700
+++ b/libgo/runtime/go-map-delete.c	Wed Jul 02 07:20:02 2014 -0700
@@ -8,6 +8,7 @@ 
 #include <stdlib.h>
 
 #include "runtime.h"
+#include "malloc.h"
 #include "go-alloc.h"
 #include "go-assert.h"
 #include "map.h"
@@ -47,7 +48,8 @@ 
       if (equalfn (key, entry + key_offset, key_size))
 	{
 	  *pentry = *(void **) entry;
-	  __go_free (entry);
+	  if (descriptor->__entry_size >= TinySize)
+	    __go_free (entry);
 	  map->__element_count -= 1;
 	  break;
 	}