Advertisement
C4Cypher

GC Magic

Aug 19th, 2014
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.33 KB | None | 0 0
  1. :- pragma foreign_decl("C", "
  2.     void * luaMR_new(void *);
  3.     void luaMR_free(void *);
  4.     ").
  5.  
  6. :- pragma foreign_code("C", "
  7.  
  8.     MR_Word * luaMR_new(MR_Word word) {
  9.         MR_Word * newptr = MR_GC_NEW_UNCOLLECTABLE(sizeof(MR_Word *));
  10.         newptr = &word;
  11.         return newptr;
  12.     }
  13.    
  14.     void luaMR_free(void * ptr) {
  15.         MR_GC_FREE(*ptr);
  16.     }
  17. ").
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement