2010-12-03 05:34:57 +01:00
|
|
|
/* go-new.c -- the generic go new() function.
|
|
|
|
|
|
|
|
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 "go-alloc.h"
|
|
|
|
#include "runtime.h"
|
2011-10-27 01:57:58 +02:00
|
|
|
#include "arch.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
#include "malloc.h"
|
2015-07-14 03:22:25 +02:00
|
|
|
#include "go-type.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
void *
|
2014-10-20 21:12:44 +02:00
|
|
|
__go_new (const struct __go_type_descriptor *td, uintptr_t size)
|
2010-12-03 05:34:57 +01:00
|
|
|
{
|
2014-10-20 21:12:44 +02:00
|
|
|
return runtime_mallocgc (size,
|
|
|
|
(uintptr) td | TypeInfo_SingleObject,
|
2015-07-14 03:22:25 +02:00
|
|
|
td->__code & GO_NO_POINTERS ? FlagNoScan : 0);
|
2010-12-03 05:34:57 +01:00
|
|
|
}
|