Original Post
Atm, I'm porting a project (libemu: http://libemu.carnivore.it/) from GCC to Visual Studio.net (C/C++) and so far, I'm a bit confused on the best way to handle this scenario. In the GCC port, there's a pointer allocation using a triple pointer (which I didn't think was possible) allocated by using malloc() for use as a double array of pointers. So, the pointer being allocated is of a void*** type which is allocated like this:
void*** em::pagetable = malloc((1 << (32 - PAGE_BITS - PAGESET_BITS)) * sizeof(void *));
And commonly used like so:
em->pagetable[PAGESET(addr)] = (void**)malloc(PAGESET_SIZE * sizeof(void *));
...
em->pagetable[PAGESET(addr)][PAGE(addr)] = malloc(PAGE_SIZE);
I feel kinda dumb for not knowing the answer to this myself, but I'm trying to get this fixed with minimal hassle. Should I try using new[][][] instead? Or use a different variable type? Thanks.
void*** em::pagetable = malloc((1 << (32 - PAGE_BITS - PAGESET_BITS)) * sizeof(void *));
And commonly used like so:
em->pagetable[PAGESET(addr)] = (void**)malloc(PAGESET_SIZE * sizeof(void *));
...
em->pagetable[PAGESET(addr)][PAGE(addr)] = malloc(PAGE_SIZE);
I feel kinda dumb for not knowing the answer to this myself, but I'm trying to get this fixed with minimal hassle. Should I try using new[][][] instead? Or use a different variable type? Thanks.