Re: valloc()?

[email protected] (Larry Jones) Thu, 3 Mar 2005 11:08:22 -0500 (EST)
Newsgroups gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs
Message-ID <[email protected]>
Derek Price writes:
> 
> Why do you cast to char * here, when ret is actually a void *?  Is this
> necessary?
> 
>   void *unaligned_ptr = xmalloc (size + pagesize - 1);
>   ret = (char *) unaligned_ptr
>         + ((- (unsigned long) unaligned_ptr) & (pagesize - 1));

Yes: unaligned_ptr is a void * and you're not allowed to do arithmetic
on void *s (except as a GCC extension), so you have to cast it to char *
first.

-Larry Jones

Honey, are we out of aspirin again? -- Calvin's Dad