Changes in / [a563f01:2f22cc4]
- Location:
- src/examples/gc_no_raii
- Files:
-
- 2 edited
-
src/gc.h (modified) (1 diff)
-
test/gctest.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/gc.h
ra563f01 r2f22cc4 7 7 static inline gcpointer(T) gcmalloc() 8 8 { 9 gcpointer(T) ptr = { gc_allocate(sizeof(T)) }; 10 ptr{}; 9 gcpointer(T) ptr; 10 void* address = gc_allocate(sizeof(T)); 11 (&ptr){ address }; 12 ctor(&ptr, address); 11 13 gc_conditional_collect(); 12 14 return ptr; 13 15 } 14 15 forall(otype T)16 static inline void gcmalloc(gcpointer(T)* ptr)17 {18 ptr{ gc_allocate(sizeof(T)) };19 (*ptr){};20 gc_conditional_collect();21 } -
src/examples/gc_no_raii/test/gctest.c
ra563f01 r2f22cc4 8 8 sout | "Bonjour au monde!\n"; 9 9 10 for(int i = 0; i < 1000000; i++) { 11 gcpointer(int) anInt; 12 gcmalloc(&anInt); 13 } 10 gcpointer(int) anInt = gcmalloc(); 14 11 }
Note:
See TracChangeset
for help on using the changeset viewer.