home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19568 < prev    next >
Encoding:
Text File  |  1993-01-12  |  1.4 KB  |  32 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!gatech!destroyer!gumby!yale!yale.edu!spool.mu.edu!howland.reston.ans.net!usc!rpi!batcomputer!munnari.oz.au!bunyip.cc.uq.oz.au!kirk!ptcburp!michi
  3. From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
  4. Subject: Re: use of REALLOC under UNIX system
  5. Message-ID: <1993Jan12.063408.3848@ptcburp.ptcbu.oz.au>
  6. Organization: Pyramid Technology Corporation
  7. References: <C0pC48.G2z@compsci.liverpool.ac.uk> <1993Jan11.221607.9595@sco.com>
  8. Date: Tue, 12 Jan 1993 06:34:08 GMT
  9. Lines: 21
  10.  
  11. md@sco.COM (Michael Davidson) writes:
  12. >The problem is that clast_str is uninitialised on your first call
  13. >to realloc()
  14.  
  15. Yes.
  16.  
  17. >- the only valid thing that you can pass to realloc()
  18. >as it's first argument is the pointer returned from a successful
  19. >call to malloc(), calloc() or realloc(). In other words, you can't
  20. >RE-allocate something that you have never allocated in the first place!
  21.  
  22. No. Under ANSI C, realloc() can be passed a NULL pointer, in which case
  23. it behaves as if malloc() was called. Initializing clast_str to NULL
  24. will fix the problem, if libc conforms to ANSI C.
  25.  
  26.                             Michi.
  27. -- 
  28.       -m------- Michael Henning                 +61 75 950255
  29.     ---mmm----- Pyramid Technology              +61 75 722475 FAX
  30.   -----mmmmm--- Research Park, Bond University  michi@ptcburp.ptcbu.oz.au
  31. -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA   uunet!munnari!ptcburp.oz!michi
  32.