source: src/examples/gc_no_raii/src/gc.h @ e297ceb

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since e297ceb was e297ceb, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

added a version of gcmalloc that uses output arguments

  • Property mode set to 100644
File size: 385 bytes
RevLine 
[15db1ab]1#pragma once
2
3#include "gcpointers.h"
[f1e42c1]4#include "internal/collector.h"
[15db1ab]5
[f1e42c1]6forall(otype T)
7static inline gcpointer(T) gcmalloc()
8{
[e297ceb]9    gcpointer(T) ptr = { gc_allocate(sizeof(T)) };
10    ptr{};
[bee4283]11    gc_conditional_collect();
12    return ptr;
[f1e42c1]13}
[e297ceb]14
15forall(otype T)
16static inline void gcmalloc(gcpointer(T)* ptr)
17{
18        ptr{ gc_allocate(sizeof(T)) };
19      (*ptr){};
20      gc_conditional_collect();
21}
Note: See TracBrowser for help on using the repository browser.