Added calloc(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-24 04:05:38 +01:00
parent b5fe020b7a
commit 4841d83ff8
2 changed files with 10 additions and 1 deletions

View File

@ -46,6 +46,7 @@ typedef int div_t, ldiv_t, lldiv_t;
/* TODO: WEXITSTATUS, WIFEXITED, WIFSIGNALED, WIFSTOPPED, WNOHANG, WSTOPSIG, WTERMSIG, WUNTRACED is missing here */
int atoi(const char*);
void* calloc(size_t, size_t);
void exit(int);
void _Exit(int status);
void free(void*);
@ -67,7 +68,6 @@ int atoi(const char*);
long atol(const char*);
long long atoll(const char*);
void* bsearch(const void*, const void*, size_t, size_t, int (*)(const void*, const void*));
void* calloc(size_t, size_t);
div_t div(int, int);
double drand48(void);
double erand48(unsigned short [3]);

View File

@ -642,6 +642,15 @@ namespace Maxsi
ASSERT(ValidateHeap());
#endif
}
extern "C" void* calloc(size_t nmemb, size_t size)
{
size_t total = nmemb * size;
void* result = Allocate(total);
if ( !result ) { return NULL; }
Memory::Set(result, 0, total);
return result;
}
}
}