Re: passing pointers [C]

From: Stephen Ramsay (sramsay_at_uga.edu)
Date: 07/09/04

  • Next message: Ulrich Eckhardt: "Re: IO-Operator overloading question"
    Date: Fri, 09 Jul 2004 05:18:19 GMT
    
    

    On 2004-07-08, Barry Schwarz <schwarzb@deloz.net> wrote:
    > Since you only call realloc, there is no way for old allocations not
    > to be released. Your problem stems from the fact that you are using
    > it incorrectly and invoking undefined behavior.
    >
    > Part of you confusion would probably disappear if you let the function
    > return the address of the newly reallocated memory instead of trying
    > to be fancy with the double pointer.

    Thanks to you (and to Bob above). It's now working like a charm. I got
    rid of the double pointer business (it seemed a bit too clever for its
    own good, but I had managed to convince me that this was the only way to
    do it).

    Note to self: You can't reallocate what wasn't allocated in the first
    place.

    Thanks again . . .

    Steve

    -- 
    Stephen Ramsay
    Department of English
    University of Georgia
    web: http://cantor.english.uga.edu/
    

  • Next message: Ulrich Eckhardt: "Re: IO-Operator overloading question"

    Relevant Pages

    • Re: realloc but not copy
      ... For reasonably large allocations, ... realloc if a data move is required. ... but then that's one reason why Vstr is designed the way it ... if (tmp = realloc(Yptr, X)) Yptr = tmp; ...
      (comp.lang.c)
    • Re: realloc but not copy
      ... For reasonably large allocations, ... realloc if a data move is required. ... the size and availability of adjacent memory chunks. ... then that's one reason why Vstr is designed the way it is (it doesn't need ...
      (comp.lang.c)
    • Re: realloc return value
      ... If realloc is successful, will the return pointer be the same as p ... same size *could* relocate it. ... future allocations. ...
      (comp.lang.c)
    • Re: realloc but not copy
      ... snip ... ... For reasonably large allocations, ... Bstrlib's the problem is that the allocated buffer is usually ... realloc if a data move is required. ...
      (comp.lang.c)