diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-01-17 12:40:45 +0100 |
commit | 3e45412327a2654a77944249962b3652e6142299 (patch) | |
tree | bc3bf69452afa055423cbe0c5cfa8ca357df6ccf /src/pkg/runtime/tiny/mem.c | |
parent | c533680039762cacbc37db8dc7eed074c3e497be (diff) | |
download | golang-upstream/2011.01.12.tar.gz |
Imported Upstream version 2011.01.12upstream/2011.01.12
Diffstat (limited to 'src/pkg/runtime/tiny/mem.c')
-rw-r--r-- | src/pkg/runtime/tiny/mem.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/pkg/runtime/tiny/mem.c b/src/pkg/runtime/tiny/mem.c index a66a4a731..7abecfba0 100644 --- a/src/pkg/runtime/tiny/mem.c +++ b/src/pkg/runtime/tiny/mem.c @@ -8,34 +8,43 @@ // Assume there's an arbitrary amount of memory starting at "end". // Sizing PC memory is beyond the scope of this demo. +static byte *allocp; + void* -SysAlloc(uintptr ask) +runtime·SysAlloc(uintptr ask) { - static byte *p; extern byte end[]; byte *q; - if(p == nil) { - p = end; - p += 7 & -(uintptr)p; + if(allocp == nil) { + allocp = end; + allocp += 7 & -(uintptr)allocp; } ask += 7 & -ask; - q = p; - p += ask; - ·memclr(q, ask); + q = allocp; + allocp += ask; + runtime·memclr(q, ask); return q; } void -SysFree(void *v, uintptr n) +runtime·SysFree(void *v, uintptr n) { - USED(v, n); + // Push pointer back if this is a free + // of the most recent SysAlloc. + n += 7 & -n; + if(allocp == (byte*)v+n) + allocp -= n; } void -SysUnused(void *v, uintptr n) +runtime·SysUnused(void *v, uintptr n) { USED(v, n); } +void +runtime·SysMemInit(void) +{ +} |