[Mesa-dev] [PATCH 3/9] Don't cast the return value of malloc/realloc
Brian Paul
brianp at vmware.com
Wed Sep 5 10:34:59 PDT 2012
On 09/05/2012 11:22 AM, Alan Coopersmith wrote:
> On 09/ 5/12 10:16 AM, Matt Turner wrote:
>> On Wed, Sep 5, 2012 at 7:30 AM, Brian Paul<brianp at vmware.com> wrote:
>>> So assigning a void pointer to a non-void pointer is legal in C and illegal
>>> in C++. I seem to recall some people compiling all of Mesa with C++ in some
>>> situations in the past. Also, there were some C compiler(s) years ago that
>>> required these casts (can't remember which).
>>
>> That would be interesting to know.
>
> The historical problem I remember was pre-ANSI C89, when compilers either didn't
> have (void *) so had malloc return (char *) or didn't have a header providing a
> declaration of malloc before C added function prototypes. I don't think any
> such compilers can still be used to build Mesa.
That's probably true. In the early days I was using HP, IBM, IRIX,
Sun, DEC, etc. compilers and they all had their idiosyncrasies.
Linux/gcc was one of the later platforms for Mesa, actually.
I don't think we've been 100% consistent about casting the results of
malloc() and nobody's complained so it's probably fine.
And I don't recall who/why someone needed to compile all of Mesa as C++.
-Brian
More information about the mesa-dev
mailing list