9-Mar-00 01:01 you wrote:
Khimenko Victor wrote:
[...] In case of GPC you can have GC-enabled new (with GC's malloc) or non GC-enabled new bot not both :-/ You can not just use gc_alloc(sizeof(record)) since if record has embedded strings or files you need to initialize it first [...]
That's not a problem since the GC-enabled malloc() can hook into GPC's run-time library where it is used instead of the usual malloc(). Initialization is done afterwards.
Arrrggghhh. Looks like I can not understood something. Let's took the following "C" snippet: -- cut -- 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); -- cut -- here is equivalent "C++" snippet: -- cut -- non_collectable_ptr=new some_struct; collectable_ptr=new(GC) some_struct; ptrfree_ptr=new(PointerFreeGC) char[BUFFER_SIZE]; -- cut --
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 ?
(and if record has virtual part then new can allocate less then gc_alloc(sizeof(record)) -- or is this Pascal's feature not implemented yet?).
It's not implemented yet, but if it were, it would not be a problem either.
Perhaps. If I'll be able to understood how to use GC at all (and no, NOT as replacement for normal new/free functions!).
P.S. If you are just replacing malloc with GC_alloc then you asking for troubles (nasty DoS attacks). In C/C++ you can EASILY avoid such attacks (see third line of each sample). Without such protection Boehm's GC is dangerous tool.