calloc crashing -- dump core

Discussion in 'C Programming' started by Sheth Raxit, Dec 4, 2007.

  1. Sheth Raxit

    Sheth Raxit Guest

    Hi

    I am debugging multithreaded/netowrk prog code, It dumps core


    hostname% gcc -v
    Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    solaris2.8/2.95.3/
    specs
    gcc version 2.95.3 20010315 (release)


    icprg04% uname -a
    SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R


    ====cut paste from dbx session this is ***dbx ./binary-name ./core
    ***
    ====
    (dbx) thread t@65
    Current function is get_remote_thick_profile
    392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    (char *)NULL)
    t@65 (l@65) stopped in realfree at 0xff0d4834
    0xff0d4834: realfree+0x00ec: st %l0, [%i0 + %o1]
    (dbx) where
    current thread: t@65
    [1] realfree(0xf0628, 0x400, 0x93b28, 0x494e3240, 0x0, 0xf0a38), at
    0xff0d4834
    [2] cleanfree(0x0, 0x10, 0x93278, 0xff139980, 0xff168284,
    0xff16fad4), at 0xff0d505c
    [3] _malloc_unlocked(0x8, 0x18, 0xec398, 0xec3a0, 0xffffffff,
    0xfefa1000), at 0xff0d41b4
    [4] malloc(0x1, 0x1, 0x94224, 0xff16fa90, 0xff168284, 0xff1709b0),
    at 0xff0d40a4
    [5] calloc(0x1, 0x1, 0x1, 0xff139980, 0xfefa1000, 0x1000), at
    0xff0c0e68
    Other Function call


    Interestingly Calloc is called as below ! and it is crashing.;
    392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    (char *)NULL)


    What i guess is...


    1. Definetly this calloc is not source of bug, but there MAY be
    memory
    corruption elsewhere.
    2. Is this Bug ? ideally calloc should not crash :) like this way.
    and
    debugger should give me the source of real-error


    --Raxit
    Sheth Raxit, Dec 4, 2007
    #1
    1. Advertising

  2. Sheth Raxit

    jacob navia Guest

    Sheth Raxit wrote:
    > Hi
    >
    > I am debugging multithreaded/netowrk prog code, It dumps core
    >
    >
    > hostname% gcc -v
    > Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > solaris2.8/2.95.3/
    > specs
    > gcc version 2.95.3 20010315 (release)
    >
    >
    > icprg04% uname -a
    > SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    >
    >
    > ====cut paste from dbx session this is ***dbx ./binary-name ./core
    > ***
    > ====
    > (dbx) thread t@65
    > Current function is get_remote_thick_profile
    > 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > (char *)NULL)


    Look again at that. And if you do not find the bug you should write 100
    times:

    "I should look carefully at the code"

    Good handwriting required!

    P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    into a char POINTER, that is probably bigger than 1 character!!!

    FIX:

    if (((*list) = (char *) calloc (1, sizeof (char *))) ==(char *)NULL)
    ^

    Note the char * instead of just char?


    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
    jacob navia, Dec 4, 2007
    #2
    1. Advertising

  3. On 4 déc, 10:26, jacob navia <> wrote:
    > Sheth Raxit wrote:
    > > Hi

    >
    > > I am debugging multithreaded/netowrk prog code, It dumps core

    >
    > > hostname% gcc -v
    > > Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > > solaris2.8/2.95.3/
    > > specs
    > > gcc version 2.95.3 20010315 (release)

    >
    > > icprg04% uname -a
    > > SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R

    >
    > > ====cut paste from dbx session this is ***dbx ./binary-name ./core
    > > ***
    > > ====
    > > (dbx) thread t@65
    > > Current function is get_remote_thick_profile
    > > 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > > (char *)NULL)

    >
    > Look again at that. And if you do not find the bug you should write 100
    > times:
    >
    > "I should look carefully at the code"
    >
    > Good handwriting required!
    >
    > P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > into a char POINTER,


    which is right...

    T* p = (T*) calloc(1, sizeof *T);

    I suspect the problem to be elsewhere.

    a+, ld.
    Laurent Deniau, Dec 4, 2007
    #3
  4. Sheth Raxit

    jacob navia Guest

    Laurent Deniau wrote:
    > On 4 déc, 10:26, jacob navia <> wrote:
    >> Sheth Raxit wrote:
    >>> Hi
    >>> I am debugging multithreaded/netowrk prog code, It dumps core
    >>> hostname% gcc -v
    >>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    >>> solaris2.8/2.95.3/
    >>> specs
    >>> gcc version 2.95.3 20010315 (release)
    >>> icprg04% uname -a
    >>> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    >>> ====cut paste from dbx session this is ***dbx ./binary-name ./core
    >>> ***
    >>> ====
    >>> (dbx) thread t@65
    >>> Current function is get_remote_thick_profile
    >>> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    >>> (char *)NULL)

    >> Look again at that. And if you do not find the bug you should write 100
    >> times:
    >>
    >> "I should look carefully at the code"
    >>
    >> Good handwriting required!
    >>
    >> P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    >> into a char POINTER,

    >
    > which is right...
    >
    > T* p = (T*) calloc(1, sizeof *T);
    >
    > I suspect the problem to be elsewhere.
    >
    > a+, ld.


    There is no *T look again. There is only sizeof(char).

    --
    jacob navia
    jacob at jacob point remcomp point fr
    logiciels/informatique
    http://www.cs.virginia.edu/~lcc-win32
    jacob navia, Dec 4, 2007
    #4
  5. "Laurent Deniau" <> schrieb im Newsbeitrag
    news:...
    <snip>
    >T* p = (T*) calloc(1, sizeof *T);

    Drop the cast to not silence a possible compiler warning about a possibly
    missing prototype

    Bye, Jojo
    Joachim Schmitz, Dec 4, 2007
    #5
  6. Sheth Raxit

    Sheth Raxit Guest

    On Dec 4, 2:26 pm, jacob navia <> wrote:
    > Sheth Raxit wrote:
    > > Hi

    >
    > > I am debugging multithreaded/netowrk prog code, It dumps core

    >
    > > hostname% gcc -v
    > > Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > > solaris2.8/2.95.3/
    > > specs
    > > gcc version 2.95.3 20010315 (release)

    >
    > > icprg04% uname -a
    > > SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R

    >
    > > ====cut paste from dbx session this is ***dbx ./binary-name ./core
    > > ***
    > > ====
    > > (dbx) thread t@65
    > > Current function is get_remote_thick_profile
    > > 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > > (char *)NULL)

    >
    > Look again at that. And if you do not find the bug you should write 100
    > times:
    >
    > "I should look carefully at the code"

    I think i need to... :) , using for loop and printf. :) :)
    >
    > Good handwriting required!
    >
    > P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > into a char POINTER, that is probably bigger than 1 character!!!

    I am trying to allocating space for one character, and later i am
    reallocating the same space.
    >
    > FIX:
    >
    > if (((*list) = (char *) calloc (1, sizeof (char *))) ==(char *)NULL)
    > ^
    >
    > Note the char * instead of just char?

    why sizeof(char *) ? return value is char* <which means pointing to
    character>, which is still correct.

    even we assume you are correct, why it is crashing. ?
    >
    > --
    > jacob navia
    > jacob at jacob point remcomp point fr
    > logiciels/informatiquehttp://www.cs.virginia.edu/~lcc-win32- Hide quoted text -
    >
    > - Show quoted text -
    Sheth Raxit, Dec 4, 2007
    #6
  7. Sheth Raxit

    Sheth Raxit Guest

    On Dec 4, 2:56 pm, jacob navia <> wrote:
    > Laurent Deniau wrote:
    > > On 4 déc, 10:26, jacob navia <> wrote:
    > >> Sheth Raxit wrote:
    > >>> Hi
    > >>> I am debugging multithreaded/netowrk prog code, It dumps core
    > >>> hostname% gcc -v
    > >>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > >>> solaris2.8/2.95.3/
    > >>> specs
    > >>> gcc version 2.95.3 20010315 (release)
    > >>> icprg04% uname -a
    > >>> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    > >>> ====cut paste from dbx session this is ***dbx ./binary-name ./core
    > >>> ***
    > >>> ====
    > >>> (dbx) thread t@65
    > >>> Current function is get_remote_thick_profile
    > >>> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > >>> (char *)NULL)
    > >> Look again at that. And if you do not find the bug you should write 100
    > >> times:

    >
    > >> "I should look carefully at the code"

    >
    > >> Good handwriting required!

    >
    > >> P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > >> into a char POINTER,

    >
    > > which is right...

    >
    > > T* p = (T*) calloc(1, sizeof *T);

    >
    > > I suspect the problem to be elsewhere.

    >
    > > a+, ld.

    >
    > There is no *T look again. There is only sizeof(char).

    actually list is passed as char **list in the function.

    int f1(char **list)
    {
    ...
    ...

    if (((*list) = (char *) calloc (1, sizeof (char))) ==(char *)NULL)
    ...
    ...
    }

    >
    > --
    > jacob navia
    > jacob at jacob point remcomp point fr
    > logiciels/informatiquehttp://www.cs.virginia.edu/~lcc-win32- Hide quoted text -
    >
    > - Show quoted text -
    Sheth Raxit, Dec 4, 2007
    #7
  8. Sheth Raxit said:

    <snip>

    > Interestingly Calloc is called as below ! and it is crashing.;
    > 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > (char *)NULL)


    You might find this easier to read if you write it as:

    *list = calloc(1, 1);
    if(*list == NULL)
    {

    Incidentally, does this re-write suggest anything to you about the amount
    of storage you're allocating?

    > What i guess is...


    Guessing isn't going to help you. What is the value of list before this
    allocation? Does it point to an existing char * object? If not,
    dereferencing it (as you do here) is asking for trouble.


    > 1. Definetly this calloc is not source of bug, but there MAY be
    > memory
    > corruption elsewhere.
    > 2. Is this Bug ? ideally calloc should not crash :) like this way.
    > and
    > debugger should give me the source of real-error


    Debuggers are not mind-readers. They're more like torches (flashlights).
    They can shine a light beam for you, but it is up to you to point it in
    the direction you want to see.

    --
    Richard Heathfield <http://www.cpax.org.uk>
    Email: -http://www. +rjh@
    Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
    "Usenet is a strange place" - dmr 29 July 1999
    Richard Heathfield, Dec 4, 2007
    #8
  9. Sheth Raxit

    Guest

    On Dec 4, 12:11 pm, Sheth Raxit <> wrote:
    > On Dec 4, 2:56 pm, jacob navia <> wrote:
    >
    > > Laurent Deniau wrote:
    > > > On 4 déc, 10:26, jacob navia <> wrote:
    > > >> Sheth Raxit wrote:
    > > >>> Hi
    > > >>> I am debugging multithreaded/netowrk prog code, It dumps core
    > > >>> hostname% gcc -v
    > > >>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > > >>> solaris2.8/2.95.3/
    > > >>> specs
    > > >>> gcc version 2.95.3 20010315 (release)
    > > >>> icprg04% uname -a
    > > >>> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    > > >>> ====cut paste from dbx session this is ***dbx ./binary-name ../core
    > > >>> ***
    > > >>> ====
    > > >>> (dbx) thread t@65
    > > >>> Current function is get_remote_thick_profile
    > > >>> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > > >>> (char *)NULL)
    > > >> Look again at that. And if you do not find the bug you should write 100
    > > >> times:

    >
    > > >> "I should look carefully at the code"

    >
    > > >> Good handwriting required!

    >
    > > >> P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > > >> into a char POINTER,

    >
    > > > which is right...

    >
    > > > T* p = (T*) calloc(1, sizeof *T);

    >
    > > > I suspect the problem to be elsewhere.

    >
    > > > a+, ld.

    >
    > > There is no *T look again. There is only sizeof(char).

    >
    > actually list is passed as char **list in the function.
    >
    > int f1(char **list)
    > {
    > ...
    > ...
    >
    > if (((*list) = (char *) calloc (1, sizeof (char))) ==(char *)NULL)
    > ...
    > ...
    >
    > }


    Please post a minimal test case that demonstrates your problem.

    That function could be valid if used like this:
    --
    char *p;
    f1(&p);
    --
    But invalid if used like this
    --
    char **p;
    f1(p);
    --

    Also, decide what language you're using, and if you find the problem
    to be somewhere outside of standard C code post in an appropriate
    newsgroup
    , Dec 4, 2007
    #9
  10. On 4 déc, 10:56, jacob navia <> wrote:
    > Laurent Deniau wrote:
    > > On 4 déc, 10:26, jacob navia <> wrote:
    > >> Sheth Raxit wrote:
    > >>> Hi
    > >>> I am debugging multithreaded/netowrk prog code, It dumps core
    > >>> hostname% gcc -v
    > >>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    > >>> solaris2.8/2.95.3/
    > >>> specs
    > >>> gcc version 2.95.3 20010315 (release)
    > >>> icprg04% uname -a
    > >>> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    > >>> ====cut paste from dbx session this is ***dbx ./binary-name ./core
    > >>> ***
    > >>> ====
    > >>> (dbx) thread t@65
    > >>> Current function is get_remote_thick_profile
    > >>> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    > >>> (char *)NULL)
    > >> Look again at that. And if you do not find the bug you should write 100
    > >> times:

    >
    > >> "I should look carefully at the code"

    >
    > >> Good handwriting required!

    >
    > >> P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > >> into a char POINTER,

    >
    > > which is right...

    >
    > > T* p = (T*) calloc(1, sizeof *T);


    oups:

    T* p = (T*) calloc(1, sizeof *p);

    > > I suspect the problem to be elsewhere.

    >
    > > a+, ld.

    >
    > There is no *T look again. There is only sizeof(char).


    s/\*T/\*p/

    still, if T is char, *p is of type char, then sizeof(char) is ok.

    a+, ld.
    Laurent Deniau, Dec 4, 2007
    #10
  11. On 4 déc, 10:57, "Joachim Schmitz" <>
    wrote:
    > "Laurent Deniau" <> schrieb im Newsbeitragnews:...
    > <snip>>T* p = (T*) calloc(1, sizeof *T);
    >
    > Drop the cast to not silence a possible compiler warning about a possibly
    > missing prototype


    I never put a cast in front of calloc/malloc/realloc. It is there
    because the PO did it (C/C++ cross-compilation?) and I wanted to show
    the idiom so I have reused to closest valid form.

    a+, ld.
    Laurent Deniau, Dec 4, 2007
    #11
  12. "Joachim Schmitz" <> schrieb im Newsbeitrag
    news:fj389l$l6f$...
    > "Laurent Deniau" <> schrieb im Newsbeitrag
    > news:...
    > <snip>
    >>T* p = (T*) calloc(1, sizeof *T);

    > Drop the cast to not silence a possible compiler warning about a possibly
    > missing prototype

    Also make it sizeof *p:
    T* p = calloc(1, sizeof *p);
    Joachim Schmitz, Dec 4, 2007
    #12
  13. "jacob navia" <> schrieb im Newsbeitrag
    news:fj388h$ifq$...
    > Laurent Deniau wrote:
    >> On 4 déc, 10:26, jacob navia <> wrote:
    >>> Sheth Raxit wrote:
    >>>> Hi
    >>>> I am debugging multithreaded/netowrk prog code, It dumps core
    >>>> hostname% gcc -v
    >>>> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    >>>> solaris2.8/2.95.3/
    >>>> specs
    >>>> gcc version 2.95.3 20010315 (release)
    >>>> icprg04% uname -a
    >>>> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    >>>> ====cut paste from dbx session this is ***dbx ./binary-name ./core
    >>>> ***
    >>>> ====
    >>>> (dbx) thread t@65
    >>>> Current function is get_remote_thick_profile
    >>>> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    >>>> (char *)NULL)
    >>> Look again at that. And if you do not find the bug you should write 100
    >>> times:
    >>>
    >>> "I should look carefully at the code"
    >>>
    >>> Good handwriting required!
    >>>
    >>> P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    >>> into a char POINTER,

    >>
    >> which is right...
    >>
    >> T* p = (T*) calloc(1, sizeof *T);
    >>
    >> I suspect the problem to be elsewhere.
    >>
    >> a+, ld.

    >
    > There is no *T look again. There is only sizeof(char).

    Look again, apparently list is a pointer to a pointer to char, so
    sizeof(char) is correct

    Bye, Jojo
    Joachim Schmitz, Dec 4, 2007
    #13
  14. "jacob navia" <> schrieb im Newsbeitrag
    news:fj36gh$ch2$...
    > Sheth Raxit wrote:
    >> Hi
    >>
    >> I am debugging multithreaded/netowrk prog code, It dumps core
    >>
    >>
    >> hostname% gcc -v
    >> Reading specs from /usr/local/lib/gcc-lib/sparc-sun-
    >> solaris2.8/2.95.3/
    >> specs
    >> gcc version 2.95.3 20010315 (release)
    >>
    >>
    >> icprg04% uname -a
    >> SunOS <host> 5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R
    >>
    >>
    >> ====cut paste from dbx session this is ***dbx ./binary-name ./core
    >> ***
    >> ====
    >> (dbx) thread t@65
    >> Current function is get_remote_thick_profile
    >> 392 if (((*list) = (char *) calloc (1, sizeof (char))) ==
    >> (char *)NULL)

    >
    > Look again at that. And if you do not find the bug you should write 100
    > times:
    >
    > "I should look carefully at the code"
    >
    > Good handwriting required!
    >
    > P.S. calloc (1,sizeof(char)) allocates ONE character. Then it is cast
    > into a char POINTER, that is probably bigger than 1 character!!!
    >
    > FIX:
    >
    > if (((*list) = (char *) calloc (1, sizeof (char *))) ==(char *)NULL)

    Not if list points to a pointer to char, which seems to be the case here.

    So better use the variable name rather than it's type and also loose the
    casts
    if (((*list) = calloc (1, sizeof **list)) == NULL)

    Here sizeof **list == sizeof char, but it has the extra benefit that you
    don't need to change this code if you change the type of list

    Bye, Jojo
    Joachim Schmitz, Dec 4, 2007
    #14
  15. Sheth Raxit

    CBFalconer Guest

    Laurent Deniau wrote:
    >

    .... snip ...
    >
    > oups:
    >
    > T* p = (T*) calloc(1, sizeof *p);

    ^^^^
    Eliminate the cast, which does nothing except suppress error
    messages. calloc returns a void*, which needs to be tested for
    non-NULL.

    And why calloc, anyhow. Whats wrong with malloc?

    --
    Chuck F (cbfalconer at maineline dot net)
    <http://cbfalconer.home.att.net>
    Try the download section.


    --
    Posted via a free Usenet account from http://www.teranews.com
    CBFalconer, Dec 4, 2007
    #15
  16. "CBFalconer" <> schrieb im Newsbeitrag
    news:...
    > Laurent Deniau wrote:
    >>

    > ... snip ...
    >>
    >> oups:
    >>
    >> T* p = (T*) calloc(1, sizeof *p);

    > ^^^^
    > Eliminate the cast, which does nothing except suppress error
    > messages. calloc returns a void*, which needs to be tested for
    > non-NULL.
    >
    > And why calloc, anyhow. Whats wrong with malloc?

    You're barking up the wrong tree, ask the OP instead. Presumably the OP
    wanted the allocated memory to be initialized to 0.

    Bye, Jojo
    Joachim Schmitz, Dec 4, 2007
    #16
  17. Sheth Raxit

    Sheth Raxit Guest

    On Dec 4, 5:26 pm, "Joachim Schmitz" <>
    wrote:
    > "CBFalconer" <> schrieb im Newsbeitragnews:...> Laurent Deniau wrote:
    >
    > > ... snip ...

    >
    > >> oups:

    >
    > >> T* p = (T*) calloc(1, sizeof *p);

    > > ^^^^
    > > Eliminate the cast, which does nothing except suppress error
    > > messages. calloc returns a void*, which needs to be tested for
    > > non-NULL.

    >
    > > And why calloc, anyhow. Whats wrong with malloc?

    >
    > You're barking up the wrong tree, ask the OP instead. Presumably the OP
    > wanted the allocated memory to be initialized to 0.

    yes.
    >
    > Bye, Jojo
    Sheth Raxit, Dec 5, 2007
    #17
  18. Sheth Raxit

    CBFalconer Guest

    Sheth Raxit wrote:
    > "Joachim Schmitz" <> wrote:
    >> "CBFalconer" <> schrieb
    >>> Laurent Deniau wrote:
    >>>
    >>> ... snip ...

    >>
    >>>> T* p = (T*) calloc(1, sizeof *p);
    >>> ^^^^
    >>> Eliminate the cast, which does nothing except suppress error
    >>> messages. calloc returns a void*, which needs to be tested for
    >>> non-NULL.

    >>
    >>> And why calloc, anyhow. What's wrong with malloc?

    >>
    >> You're barking up the wrong tree, ask the OP instead. Presumably
    >> the OP wanted the allocated memory to be initialized to 0.

    >
    > yes.


    Why? It only allocates one byte.

    --
    Chuck F (cbfalconer at maineline dot net)
    <http://cbfalconer.home.att.net>
    Try the download section.



    --
    Posted via a free Usenet account from http://www.teranews.com
    CBFalconer, Dec 5, 2007
    #18
  19. Sheth Raxit

    Flash Gordon Guest

    CBFalconer wrote, On 05/12/07 08:37:
    > Sheth Raxit wrote:
    >> "Joachim Schmitz" <> wrote:
    >>> "CBFalconer" <> schrieb
    >>>> Laurent Deniau wrote:
    >>>>
    >>>> ... snip ...
    >>>>> T* p = (T*) calloc(1, sizeof *p);
    >>>> ^^^^
    >>>> Eliminate the cast, which does nothing except suppress error
    >>>> messages. calloc returns a void*, which needs to be tested for
    >>>> non-NULL.
    >>>> And why calloc, anyhow. What's wrong with malloc?
    >>> You're barking up the wrong tree, ask the OP instead. Presumably
    >>> the OP wanted the allocated memory to be initialized to 0.

    >> yes.

    >
    > Why? It only allocates one byte.


    Presumable the OP wants that one byte initialised to 0.
    --
    Flash Gordon
    Flash Gordon, Dec 5, 2007
    #19
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike
    Replies:
    0
    Views:
    691
  2. BlueDoze
    Replies:
    2
    Views:
    1,092
    Gordon Beaton
    May 4, 2004
  3. Amit
    Replies:
    0
    Views:
    954
  4. Replies:
    3
    Views:
    6,930
    Gordon Beaton
    Nov 22, 2005
  5. halfdog
    Replies:
    12
    Views:
    12,405
Loading...

Share This Page