diff options
author | Guido van Rossum <guido@python.org> | 1992-12-14 16:59:51 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1992-12-14 16:59:51 +0000 |
commit | 932056168e3bcb4be1158cdca93d643460d5c3e9 (patch) | |
tree | 08018b39686e5a4d0d045916b1677b254cde9451 /Include/mymalloc.h | |
parent | d668782a87bd74a08f1642d495e92a0b5505d474 (diff) | |
download | cpython-932056168e3bcb4be1158cdca93d643460d5c3e9.tar.gz |
* mymalloc.h: always allocate one extra byte, since some malloc's
return NULL for malloc(0) or realloc(p, 0). (This should be done
differently than wasting one byte, but alas...)
* Moved "add'l libraries" option in Makefile to an earlier place.
* Remove argument compatibility hacks (b) and (c).
* Add grey2mono, dither2mono and mono2grey to imageop.
* Dup the fd in socket.fromfd().
* Added new modules mpz, md5 (by JH, requiring GNU MP 1.2). Affects
Makefile and config.c.
* socketmodule.c: added socket.fromfd(fd, family, type, [proto]),
converted socket() to use of getargs().
Diffstat (limited to 'Include/mymalloc.h')
-rw-r--r-- | Include/mymalloc.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Include/mymalloc.h b/Include/mymalloc.h index aadd0f3048..e4315bdb98 100644 --- a/Include/mymalloc.h +++ b/Include/mymalloc.h @@ -53,12 +53,14 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #define NULL 0 #endif -#define NEW(type, n) ( (type *) malloc((n) * sizeof(type)) ) +/* XXX Always allocate one extra byte, since some malloc's return NULL + XXX for malloc(0) or realloc(p, 0). */ +#define NEW(type, n) ( (type *) malloc(1 + (n) * sizeof(type)) ) #define RESIZE(p, type, n) \ if ((p) == NULL) \ - (p) = (type *) malloc((n) * sizeof(type)); \ + (p) = (type *) malloc(1 + (n) * sizeof(type)); \ else \ - (p) = (type *) realloc((ANY *)(p), (n) * sizeof(type)) + (p) = (type *) realloc((ANY *)(p), 1 + (n) * sizeof(type)) #define DEL(p) free((ANY *)p) #define XDEL(p) if ((p) == NULL) ; else DEL(p) |