|
@ -32,11 +32,13 @@ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
#if defined(LIBC_SCCS) && !defined(lint) |
|
|
#if defined(LIBC_SCCS) && !defined(lint) |
|
|
static char *rcsid = "$OpenBSD: calloc.c,v 1.5 1999/11/10 20:12:31 millert Exp $"; |
|
|
|
|
|
|
|
|
static char *rcsid = "$OpenBSD: calloc.c,v 1.6 2002/07/30 00:11:07 deraadt Exp $"; |
|
|
#endif /* LIBC_SCCS and not lint */ |
|
|
#endif /* LIBC_SCCS and not lint */ |
|
|
|
|
|
|
|
|
#include <stdlib.h> |
|
|
#include <stdlib.h> |
|
|
#include <string.h> |
|
|
#include <string.h> |
|
|
|
|
|
#include <limits.h> |
|
|
|
|
|
#include <errno.h> |
|
|
|
|
|
|
|
|
void * |
|
|
void * |
|
|
calloc(num, size) |
|
|
calloc(num, size) |
|
@ -45,6 +47,10 @@ calloc(num, size) |
|
|
{ |
|
|
{ |
|
|
register void *p; |
|
|
register void *p; |
|
|
|
|
|
|
|
|
|
|
|
if (SIZE_T_MAX / num < size) { |
|
|
|
|
|
errno = ENOMEM; |
|
|
|
|
|
return NULL; |
|
|
|
|
|
} |
|
|
size *= num; |
|
|
size *= num; |
|
|
p = malloc(size); |
|
|
p = malloc(size); |
|
|
if (p) |
|
|
if (p) |
|
|