home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- 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
- From: michi@ptcburp.ptcbu.oz.au (Michael Henning)
- Subject: Re: use of REALLOC under UNIX system
- Message-ID: <1993Jan12.063408.3848@ptcburp.ptcbu.oz.au>
- Organization: Pyramid Technology Corporation
- References: <C0pC48.G2z@compsci.liverpool.ac.uk> <1993Jan11.221607.9595@sco.com>
- Date: Tue, 12 Jan 1993 06:34:08 GMT
- Lines: 21
-
- md@sco.COM (Michael Davidson) writes:
- >The problem is that clast_str is uninitialised on your first call
- >to realloc()
-
- Yes.
-
- >- the only valid thing that you can pass to realloc()
- >as it's first argument is the pointer returned from a successful
- >call to malloc(), calloc() or realloc(). In other words, you can't
- >RE-allocate something that you have never allocated in the first place!
-
- No. Under ANSI C, realloc() can be passed a NULL pointer, in which case
- it behaves as if malloc() was called. Initializing clast_str to NULL
- will fix the problem, if libc conforms to ANSI C.
-
- Michi.
- --
- -m------- Michael Henning +61 75 950255
- ---mmm----- Pyramid Technology +61 75 722475 FAX
- -----mmmmm--- Research Park, Bond University michi@ptcburp.ptcbu.oz.au
- -------mmmmmmm- Gold Coast, Q 4229, AUSTRALIA uunet!munnari!ptcburp.oz!michi
-