9-Mar-00 10:33 you wrote:
Khimenko Victor wrote:
non_collectable_ptr=(struct some_struct *)malloc(sizeof(some_struct)); collectable_ptr=(struct some_struct *)GC_malloc(sizeof(some_struct)); ptrfree_ptr=(char *)GC_malloc_atomic(BUFFER_SIZE);
What's the difference between GC_malloc() and GC_malloc_atomic()?
When you are allocating buffer with GC_alloc_atomic you are GURANTEE that in that buffer you will not store pointers. It'll speedup GC's work but what's is MUCH more important is that if content of that buffer come from outside GC can not go nuts anymore (no matter what is stored in buffer GC will not interpret is as pointer to object so malicious user can not fool GC). Yes, porbably exploit is not easy (not THAT hard also: pointer to some byte in structure is enough to make this structure non-collectable; Boehm's GC should cope with "C"!) but 1) it's not good style 2) if exploit can be prevented easily then better to to this.
What's pascal equivalent ? I repeat: I can understood that if I'll replace malloc with gc_alloc globally GPC's new will work just fine. But how I can use GC and old tried malloc/free in ONE program ?
I'd suggest to write two procedures to flip the hook between normal allocation and using the GC. I also see that this makes problems with threads ... have to think about that ...