This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: egcs-19980531, warning patches [part 1/2]
- To: egcs at cygnus dot com
- Subject: Re: egcs-19980531, warning patches [part 1/2]
- From: Stephen Williams <steve at icarus dot icarus dot com>
- Date: Sat, 06 Jun 1998 10:29:22 -0700
law@cygnus.com said:
> Note that while calloc may be ANSI and available on systems as far
> back as the pdp11 era, it may not be available on embedded targets.
Could not calloc can be faked like so, for targets that don't have it?
(*My* embedded target does have calloc:-)
# include <stdlib.h>
# include <string.h>
extern "C" void* calloc(size_t nmemb, size_t size)
{
size_t fudged_size = size * nmemb;
void*result = malloc(fudged_size);
if (result) memset(result, 0, fudged_size);
return result;
}
--
Steve Williams "The woods are lovely, dark and deep.
steve@icarus.com But I have promises to keep,
steve@picturel.com and lines to code before I sleep,
http://www.picturel.com And lines to code before I sleep."