diff options
author | millert@openbsd.org <millert@openbsd.org> | 2015-02-06 23:21:59 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-02-09 09:28:17 +1100 |
commit | fd36834871d06a03e1ff8d69e41992efa1bbf85f (patch) | |
tree | 95390638f8f92dfd017176d558acec1e91a9e3b0 /xmalloc.c | |
parent | 1910a286d7771eab84c0b047f31c0a17505236fa (diff) |
upstream commit
SIZE_MAX is standard, we should be using it in preference to
the obsolete SIZE_T_MAX. OK miod@ beck@
Diffstat (limited to 'xmalloc.c')
-rw-r--r-- | xmalloc.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: xmalloc.c,v 1.30 2015/01/16 06:40:12 deraadt Exp $ */ | 1 | /* $OpenBSD: xmalloc.c,v 1.31 2015/02/06 23:21:59 millert Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -16,10 +16,10 @@ | |||
16 | #include "includes.h" | 16 | #include "includes.h" |
17 | 17 | ||
18 | #include <stdarg.h> | 18 | #include <stdarg.h> |
19 | #include <stdint.h> | ||
19 | #include <stdio.h> | 20 | #include <stdio.h> |
20 | #include <stdlib.h> | 21 | #include <stdlib.h> |
21 | #include <string.h> | 22 | #include <string.h> |
22 | #include <limits.h> | ||
23 | 23 | ||
24 | #include "xmalloc.h" | 24 | #include "xmalloc.h" |
25 | #include "log.h" | 25 | #include "log.h" |
@@ -44,8 +44,8 @@ xcalloc(size_t nmemb, size_t size) | |||
44 | 44 | ||
45 | if (size == 0 || nmemb == 0) | 45 | if (size == 0 || nmemb == 0) |
46 | fatal("xcalloc: zero size"); | 46 | fatal("xcalloc: zero size"); |
47 | if (SIZE_T_MAX / nmemb < size) | 47 | if (SIZE_MAX / nmemb < size) |
48 | fatal("xcalloc: nmemb * size > SIZE_T_MAX"); | 48 | fatal("xcalloc: nmemb * size > SIZE_MAX"); |
49 | ptr = calloc(nmemb, size); | 49 | ptr = calloc(nmemb, size); |
50 | if (ptr == NULL) | 50 | if (ptr == NULL) |
51 | fatal("xcalloc: out of memory (allocating %zu bytes)", | 51 | fatal("xcalloc: out of memory (allocating %zu bytes)", |
@@ -61,8 +61,8 @@ xrealloc(void *ptr, size_t nmemb, size_t size) | |||
61 | 61 | ||
62 | if (new_size == 0) | 62 | if (new_size == 0) |
63 | fatal("xrealloc: zero size"); | 63 | fatal("xrealloc: zero size"); |
64 | if (SIZE_T_MAX / nmemb < size) | 64 | if (SIZE_MAX / nmemb < size) |
65 | fatal("xrealloc: nmemb * size > SIZE_T_MAX"); | 65 | fatal("xrealloc: nmemb * size > SIZE_MAX"); |
66 | if (ptr == NULL) | 66 | if (ptr == NULL) |
67 | new_ptr = malloc(new_size); | 67 | new_ptr = malloc(new_size); |
68 | else | 68 | else |