bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gnulib] valloc()?


From: Larry Jones
Subject: Re: [bug-gnulib] valloc()?
Date: Thu, 3 Mar 2005 11:08:22 -0500 (EST)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]