summaryrefslogtreecommitdiff
path: root/src/runtime/malloc.h
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2008-12-19 03:13:39 -0800
committerRuss Cox <rsc@golang.org>2008-12-19 03:13:39 -0800
commit902c03dbf5832d103d487160db5b1a414b8cad3d (patch)
tree9b40150f73466d543e7724ee596fb3c4ef094e72 /src/runtime/malloc.h
parent9aa0ed4a0fe2a53fffc6011a64dfbb4346d18fe8 (diff)
downloadgolang-902c03dbf5832d103d487160db5b1a414b8cad3d.tar.gz
malloc bug fixes.
use malloc by default. free stacks. R=r DELTA=424 (333 added, 29 deleted, 62 changed) OCL=21553 CL=21584
Diffstat (limited to 'src/runtime/malloc.h')
-rw-r--r--src/runtime/malloc.h19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/runtime/malloc.h b/src/runtime/malloc.h
index e2a4af9ef..9c71e631a 100644
--- a/src/runtime/malloc.h
+++ b/src/runtime/malloc.h
@@ -62,7 +62,7 @@
// 4. If the heap has too much memory, return some to the
// operating system.
//
-// TODO(rsc): Steps 2, 3, 4 are not implemented.
+// TODO(rsc): Step 4 is not implemented.
//
// Allocating and freeing a large object uses the page heap
// directly, bypassing the MCache and MCentral free lists.
@@ -79,6 +79,7 @@ typedef struct MHeapMap MHeapMap;
typedef struct MHeapMapCache MHeapMapCache;
typedef struct MSpan MSpan;
typedef struct MStats MStats;
+typedef struct MLink MLink;
enum
{
@@ -102,6 +103,12 @@ enum
};
+// A generic linked list of blocks. (Typically the block is bigger than sizeof(MLink).)
+struct MLink
+{
+ MLink *next;
+};
+
// SysAlloc obtains a large chunk of memory from the operating system,
// typically on the order of a hundred kilobytes or a megabyte.
//
@@ -129,7 +136,7 @@ struct FixAlloc
{
uintptr size;
void *(*alloc)(uintptr);
- void *list;
+ MLink *list;
byte *chunk;
uint32 nchunk;
};
@@ -146,6 +153,7 @@ struct MStats
{
uint64 alloc;
uint64 sys;
+ uint64 stacks;
};
extern MStats mstats;
@@ -175,8 +183,9 @@ extern void InitSizes(void);
typedef struct MCacheList MCacheList;
struct MCacheList
{
- void *list;
+ MLink *list;
uint32 nlist;
+ uint32 nlistmin;
};
struct MCache
@@ -230,8 +239,8 @@ struct MCentral
};
void MCentral_Init(MCentral *c, int32 sizeclass);
-int32 MCentral_AllocList(MCentral *c, int32 n, void **start, void **end);
-void MCentral_FreeList(MCentral *c, int32 n, void *start, void *end);
+int32 MCentral_AllocList(MCentral *c, int32 n, MLink **first);
+void MCentral_FreeList(MCentral *c, int32 n, MLink *first);
// Free(v) must be able to determine the MSpan containing v.