[Gc] Interior pointers

Bruce Hoult bruce at hoult.org
Fri Dec 28 21:44:21 PST 2012


int off_to_name = sizeof(long) + sizeof(off_t) + sizeof(short);

That's not reliable, though it seems to be working for you. Things an
be packed to different sizes when they are in structures than when
they are stand-alone.

Look up offsetof(), or at least use  (size_t)(((struct linux_dirent*)0)->d_name)


/* array holding pointers to 5000 names */
  char **allnames = (char **) GC_MALLOC(5000);

Not unless pointers are 1 byte on your machine.

So, this array is overflowing, as guessed by both of us.

On Sat, Dec 29, 2012 at 6:21 PM, Michael Talbot-Wilson <mtw at view.net.au> wrote:
> Guys, thanks.  Here is the full program.  (Assuming I can send an
> attachment to this mailing list.)
>
> Hope you can put me straight.
>
> --Mike
>
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/


More information about the Gc mailing list