GC API: Difference between revisions

172 bytes removed ,  11 April 2008
simpler API
(layout/alignment/OOM notes)
(simpler API)
Line 183: Line 183:
== Rooting ==
== Rooting ==


  typedef struct GCRoot {
The rooting API provides a simple way to treat a particular GC object as a root. More complex rooting scenarios can be accomplished with a precollect hook.
  GCRoot *next; /* managed by the gc */
 
  GCRoot *prev; /* managed by the gc */
  typedef struct GCRoot GCRoot; /* opaque */
  GCLayout *layout;
  void *address;
} gc_Root;
   
   
  void '''gc_add_root'''(
  GCRoot* '''gc_root_object'''(
   GCRoot *root);
   void *gcobject);


Mark a section of memory as a GC root. The application is responsible for allocating the memory for the gc_Root structure, which may be part of a larger allocation. The gc is responsible for maintaining the next/prev linked list. The application may alter the root address, size, and conservative nature within any request.  
Treat gcobject as a root. <var>gcobject</var> must have been allocated with a GC allocation function.


  void '''gc_remove_root'''(
  void '''gc_remove_root'''(
Confirmed users, Bureaucrats and Sysops emeriti
1,217

edits