diff options
| author | Jan Ziak <0xe2.0x9a.0x9b@gmail.com> | 2012-10-21 17:41:32 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2012-10-21 17:41:32 -0400 |
| commit | 4a191c2c1b3fe1325ab8617472aef628fd494076 (patch) | |
| tree | f257db791881a8690e69ae85100f4d8b01a4f161 /src/pkg/runtime/malloc.goc | |
| parent | 4545dc6a6953b2be6d0d50719ad165d46278d9bf (diff) | |
| download | go-4a191c2c1b3fe1325ab8617472aef628fd494076.tar.xz | |
runtime: store types of allocated objects
R=rsc
CC=golang-dev
https://golang.org/cl/6569057
Diffstat (limited to 'src/pkg/runtime/malloc.goc')
| -rw-r--r-- | src/pkg/runtime/malloc.goc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/pkg/runtime/malloc.goc b/src/pkg/runtime/malloc.goc index 7507eb52d0..eaae52a641 100644 --- a/src/pkg/runtime/malloc.goc +++ b/src/pkg/runtime/malloc.goc @@ -708,6 +708,26 @@ runtime·new(Type *typ, uint8 *ret) FLUSH(&ret); } +// same as runtime·new, but callable from C +void* +runtime·cnew(Type *typ) +{ + uint32 flag; + void *ret; + + m->racepc = runtime·getcallerpc(&typ); + flag = typ->kind&KindNoPointers ? FlagNoPointers : 0; + ret = runtime·mallocgc(typ->size, flag, 1, 1); + + if(UseSpanType && !flag) { + if(false) { + runtime·printf("new %S: %p\n", *typ->string, ret); + } + runtime·settype(ret, (uintptr)typ | TypeInfo_SingleObject); + } + return ret; +} + void* runtime·stackalloc(uint32 n) { |
