Check-in [82425545ff]

Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
SHA1 Hash:82425545ff388bcf4862e9ddbcd4fc9f8ead0a22
Date: 2009-06-08 20:52:13
User: stephan
Comment:minor doc updates
Tags And Properties
Changes
hide diffs unified diffs patch

Changes to whgc.h

Old (78d0261b2af5fcdd) New (38ead59a2f5732f7)
1 #ifndef WANDERINGHORSE_NET_WHGC_H_INCLUDED 1 #ifndef WANDERINGHORSE_NET_WHGC_H_INCLUDED
2 #define WANDERINGHORSE_NET_WHGC_H_INCLUDED 2 #define WANDERINGHORSE_NET_WHGC_H_INCLUDED
3 3
4 #include <stdarg.h> 4 #include <stdarg.h>
5 #include <stddef.h> 5 #include <stddef.h>
75 hidden lines
81 whgc_context * cx = whgc_create_context( 0 ); 81 whgc_context * cx = whgc_create_context( 0 );
82 if( ! cx ) { ... error, probably OOM ... } 82 if( ! cx ) { ... error, probably OOM ... }
83 83
84 int * i = (int*)malloc(sizeof(int)); 84 int * i = (int*)malloc(sizeof(int));
85 *i = 42; 85 *i = 42;
86 whgc_add( i, free ); | 86 whgc_add( cx, i, free );
87 87
88 struct mystruct * my = (struct mystruct*)malloc(sizeof(struct mystruct)); 88 struct mystruct * my = (struct mystruct*)malloc(sizeof(struct mystruct));
89 my->foo = "hi"; 89 my->foo = "hi";
90 my->bar = 42.42; 90 my->bar = 42.42;
91 // Assume this function exists: 91 // Assume this function exists:
52 hidden lines
144 If cx is null this function works just like malloc() except: 144 If cx is null this function works just like malloc() except:
145 145
146 - It calls memset() to zero out the memory. 146 - It calls memset() to zero out the memory.
147 147
148 - If cx is not null then ownership of the memory transfers is 148 - If cx is not null then ownership of the memory transfers is
149 transfered to cx calling whgc_add(cx,theMemory,dtor). cx's memory | 149 transfered to cx calling whgc_add(cx,theMemory,dtor). cx's
150 memory allocation telemetry (see whgc_get_stats()) is also updated. | 150 memory allocation telemetry (see whgc_get_stats()) is also
| 151 updated.
151 152
152 - If the cx is null then the caller owns the returned memory and must free 153 - If the cx is null then the caller owns the returned memory and must free
153 it by passing it to free(). 154 it by passing it to free().
154 155
155 It returns 0 on an alloc error or if size is 0. 156 It returns 0 on an alloc error or if size is 0.
11 hidden lines
167 Returns the client-supplied pointer which was passed to 168 Returns the client-supplied pointer which was passed to
168 whgc_create_context() for the given context. It is sometimes 169 whgc_create_context() for the given context. It is sometimes
169 useful as a lookup key. 170 useful as a lookup key.
170 */ 171 */
171 void const * whgc_get_context_client(whgc_context const *); 172 void const * whgc_get_context_client(whgc_context const *);
172 <
173 173
174 /** 174 /**
175 Registers an arbitrary key and value with the given garbage 175 Registers an arbitrary key and value with the given garbage
176 collector, such that whgc_destroy_context(st) will clean up the 176 collector, such that whgc_destroy_context(st) will clean up the
177 resources using the given destructor functions (which may be 0, 177 resources using the given destructor functions (which may be 0,
269 hidden lines
447 } /* extern "C" */ 447 } /* extern "C" */
448 #endif 448 #endif
449 449
450 450
451 #endif /* WANDERINGHORSE_NET_WHGC_H_INCLUDED */ 451 #endif /* WANDERINGHORSE_NET_WHGC_H_INCLUDED */