This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: egcs-19980531, warning patches [part 1/2]



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."




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]