Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!haven!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: realloc() (was: Re: Safe coding practices) Message-ID: <15301@smoke.brl.mil> Date: 23 Feb 91 20:09:37 GMT References: <1991Jan30.204159.5726@athena.mit.edu> <263@nazgul.UUCP> <6461@stpstn.UUCP> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 16 In article <6461@stpstn.UUCP> lerman@stpstn.UUCP (Ken Lerman) writes: >So the solution is to "#define realloc Realloc" in my code so I can link >my Realloc with my program. You should not in general attempt to replace functions normally provided by the standard C library with your own implementations, because it is unlikely that you will know precisely what non-obvious constraints the C library implementation has adopted. (Often there are subtle things that need to be taken care of within the C library of which most programmers are unaware.) This is especially problematic for memory allocation. If you feel the need to provide your own spiffy memory allocation interface, use your OWN NAMES for those functions and have them call upon the standard C memory allocation functions as required. (This could take the form of one huge allocation at the beginning of an application, which is subsequently doled out in pieces by your own functions. Other approaches are also feasible.)