RE: Help with malloc

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

 



Hi All

Thanks very much for your very valid inputs. I did as suggested and
instead of checking to see if the pointer returned -ve (this was legacy
code not mine :-)), I changed it to check for null and continued to use
this pointer and all worked fine so far.

Thanks much for the advice.

With Regards

Vardhan 

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of Austin, Alex
Sent: Friday, October 10, 2008 2:58 PM
To: 'Andrew Bell'; Vardhan, Sundara (GE Infra, Energy)
Cc: gcc-help@xxxxxxxxxxx
Subject: RE: Help with malloc

In other words, it just so happens that the address space used when you
alloc that much is >2GB, so the first bit is set which appears as a
negative number if you cast it to a signed int. It is a valid pointer,
so just use it.

-----Original Message-----
From: gcc-help-owner@xxxxxxxxxxx [mailto:gcc-help-owner@xxxxxxxxxxx] On
Behalf Of Andrew Bell
Sent: Friday, October 10, 2008 1:34 PM
To: Vardhan, Sundara (GE Infra, Energy)
Cc: gcc-help@xxxxxxxxxxx
Subject: Re: Help with malloc

On Fri, Oct 10, 2008 at 1:30 PM, Vardhan, Sundara (GE Infra, Energy)
<sundara.vardhan@xxxxxx> wrote:
> Hi All
>
>        Desperate: Do not know if this is the right forum for this 
> question. Using gcc 4.1.1 on Red Hat Linux, I keep getting negative 
> pointer value when I try to allocate more than 128000 bytest using 
> malloc(). Works fine if the value is less than 128000. Any ideas why 
> this happens. I would very much appreciate your help and input.

RETURN VALUE
       For  calloc()  and  malloc(),  the  value returned is a pointer
to the
       allocated memory, which is suitably aligned for any kind of
variable,
       or NULL if the request fails.

--
Andrew Bell
andrew.bell.ia@xxxxxxxxx


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux