~ubuntu-branches/ubuntu/quantal/libgc/quantal

« back to all changes in this revision

Viewing changes to include/gc_cpp.h

  • Committer: Bazaar Package Importer
  • Author(s): Christoph Egger
  • Date: 2011-02-19 12:19:56 UTC
  • mfrom: (1.3.2 upstream) (0.1.5 experimental)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20110219121956-67rb69xlt5nud3v2
Tags: 1:7.1-5
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    class A: public gc {...};
49
49
    A* a = new (NoGC) A;   // a is uncollectable.
50
50
 
 
51
The new(PointerFreeGC) syntax allows the allocation of collectable
 
52
objects that are not scanned by the collector.  This useful if you
 
53
are allocating compressed data, bitmaps, or network packets.  (In
 
54
the latter case, it may remove danger of unfriendly network packets
 
55
intentionally containing values that cause spurious memory retention.)
 
56
 
51
57
Both uncollectable and collectable objects can be explicitly deleted
52
58
with "delete", which invokes an object's destructors and frees its
53
59
storage immediately.
80
86
 
81
87
Cautions:
82
88
 
83
 
1. Be sure the collector has been augmented with "make c++".
 
89
1. Be sure the collector has been augmented with "make c++" or
 
90
"--enable-cplusplus".
84
91
 
85
92
2.  If your compiler supports the new "operator new[]" syntax, then
86
93
add -DGC_OPERATOR_NEW_ARRAY to the Makefile.
111
118
that preserves the correct exception semantics requires a language
112
119
extension, e.g. the "gc" keyword.)
113
120
 
114
 
4. Compiler bugs:
 
121
4. Compiler bugs (now hopefully history):
115
122
 
116
123
* Solaris 2's CC (SC3.0) doesn't implement t->~T() correctly, so the
117
124
destructors of classes derived from gc_cleanup won't be invoked.
170
177
        /* Must be redefined here, since the other overloadings */
171
178
        /* hide the global definition.                          */
172
179
    inline void operator delete( void* obj );
173
 
#   ifdef GC_PLACEMENT_DELETE  
 
180
#   ifdef GC_PLACEMENT_DELETE
 
181
      inline void operator delete( void*, GCPlacement );
 
182
        /* called if construction fails.        */
174
183
      inline void operator delete( void*, void* );
175
184
#   endif
176
185
 
180
189
    inline void* operator new[]( size_t size, void *p );
181
190
    inline void operator delete[]( void* obj );
182
191
#   ifdef GC_PLACEMENT_DELETE
 
192
      inline void operator delete[]( void*, GCPlacement );
183
193
      inline void operator delete[]( void*, void* );
184
194
#   endif
185
195
#endif /* GC_OPERATOR_NEW_ARRAY */
228
238
    classes derived from "gc_cleanup" or containing members derived
229
239
    from "gc_cleanup". */
230
240
 
 
241
#   ifdef GC_PLACEMENT_DELETE
 
242
      inline void operator delete( void*, GCPlacement, GCCleanUpFunc, void * );
 
243
#   endif
231
244
 
232
245
#ifdef _MSC_VER
233
246
 /** This ensures that the system default operator new[] doesn't get
234
247
  *  undefined, which is what seems to happen on VC++ 6 for some reason
235
248
  *  if we define a multi-argument operator new[].
236
 
  *  There seems to be really redirect new in this environment without
 
249
  *  There seems to be no way to redirect new in this environment without
237
250
  *  including this everywhere. 
238
251
  */
239
252
 void *operator new[]( size_t size );
289
302
    
290
303
#ifdef GC_PLACEMENT_DELETE
291
304
  inline void gc::operator delete( void*, void* ) {}
 
305
 
 
306
  inline void gc::operator delete( void* p, GCPlacement gcp ) {
 
307
    GC_FREE(p);
 
308
  }
292
309
#endif
293
310
 
294
311
#ifdef GC_OPERATOR_NEW_ARRAY
307
324
 
308
325
#ifdef GC_PLACEMENT_DELETE
309
326
  inline void gc::operator delete[]( void*, void* ) {}
 
327
 
 
328
  inline void gc::operator delete[]( void* p, GCPlacement gcp ) {
 
329
    gc::operator delete(p); }
 
330
 
310
331
#endif
311
332
    
312
333
#endif /* GC_OPERATOR_NEW_ARRAY */
349
370
        obj = GC_MALLOC_UNCOLLECTABLE( size );};
350
371
    return obj;}
351
372
        
 
373
# ifdef GC_PLACEMENT_DELETE
 
374
inline void operator delete ( 
 
375
    void *p, 
 
376
    GCPlacement gcp,
 
377
    GCCleanUpFunc cleanup,
 
378
    void* clientData )
 
379
{
 
380
    GC_FREE(p);
 
381
}
 
382
# endif
352
383
 
353
384
#ifdef GC_OPERATOR_NEW_ARRAY
354
385