2008-12-04 22:04:26 -07:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "malloc.h"
|
|
|
|
|
|
|
|
void*
|
|
|
|
stackalloc(uint32 n)
|
|
|
|
{
|
|
|
|
void *v;
|
2008-12-05 16:24:18 -07:00
|
|
|
int32 *ref;
|
2008-12-04 22:04:26 -07:00
|
|
|
|
|
|
|
v = alloc(n);
|
|
|
|
//printf("stackalloc %d = %p\n", n, v);
|
2008-12-05 16:24:18 -07:00
|
|
|
ref = nil;
|
|
|
|
findobj(v, nil, nil, &ref);
|
|
|
|
*ref = RefStack;
|
2008-12-04 22:04:26 -07:00
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
stackfree(void *v)
|
|
|
|
{
|
|
|
|
//printf("stackfree %p\n", v);
|
|
|
|
free(v);
|
|
|
|
}
|
2008-12-05 16:24:18 -07:00
|
|
|
|
|
|
|
void*
|
|
|
|
mal(uint32 n)
|
|
|
|
{
|
|
|
|
return alloc(n);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
sys·mal(uint32 n, uint8 *ret)
|
|
|
|
{
|
|
|
|
ret = alloc(n);
|
|
|
|
FLUSH(&ret);
|
|
|
|
}
|