go-new.c 641 B

123456789101112131415161718192021222324252627
  1. /* go-new.c -- the generic go new() function.
  2. Copyright 2009 The Go Authors. All rights reserved.
  3. Use of this source code is governed by a BSD-style
  4. license that can be found in the LICENSE file. */
  5. #include "go-alloc.h"
  6. #include "runtime.h"
  7. #include "arch.h"
  8. #include "malloc.h"
  9. void *
  10. __go_new (const struct __go_type_descriptor *td, uintptr_t size)
  11. {
  12. return runtime_mallocgc (size,
  13. (uintptr) td | TypeInfo_SingleObject,
  14. 0);
  15. }
  16. void *
  17. __go_new_nopointers (const struct __go_type_descriptor *td, uintptr_t size)
  18. {
  19. return runtime_mallocgc (size,
  20. (uintptr) td | TypeInfo_SingleObject,
  21. FlagNoScan);
  22. }