Andreas Raab wrote:
Actually, this is an interesting thought. I have the need for managing a dynamic array of roots but this could be handled just as easily by tracking a variable pointing to a Squeak array.
A variable in C is more-or-less a one-place array, so perhaps supporting arrays is the simpler option?
{ sqInt myRoot = ...; vm->addToVmRoots(&myRoot, 1, NULL); ... vm->addToVmRoots(NULL, 0, &myRoot); }
#define WITH_ROOT(vm, var, blk) \ { (vm)->addToVmRoots(&(var), 1, NULL); \ blk; \ (vm)->addToVmRoots(NULL, 0, &(var)); }
{ sqInt myRoot2 = ...; WITH_ROOT(vm, myRoot2, { ... }); }