From a8e3154b7affdecd27062349c4466c38f3b565b1 Mon Sep 17 00:00:00 2001 From: tg Date: Mon, 23 Mar 2009 10:31:15 +0000 Subject: [PATCH] =?UTF-8?q?sometimes=20I=20have=20tomatoes=20on=20my=20eye?= =?UTF-8?q?s=20(or=20is=20it=20the=20CRT=20monitor=3F)=20make=20SIZE=5FMAX?= =?UTF-8?q?=20portable,=2010x=20to=20Jonathan=20=E2=80=9CciruZ=E2=80=9D=20?= =?UTF-8?q?Schleifer=20for=20the=20hint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lalloc.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lalloc.c b/lalloc.c index 117c890..6f8c693 100644 --- a/lalloc.c +++ b/lalloc.c @@ -1,6 +1,14 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.2 2009/03/23 09:08:35 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/lalloc.c,v 1.3 2009/03/23 10:31:15 tg Exp $"); + +#ifndef SIZE_MAX +#ifdef SIZE_T_MAX +#define SIZE_MAX SIZE_T_MAX +#else +#define SIZE_MAX ((size_t)-1) +#endif +#endif struct lalloc { struct lalloc *next; /* entry pointer, must be first */ @@ -33,10 +41,8 @@ aresize(void *ptr, size_t numb, Area *ap) { struct lalloc *lp, *pp; -#ifdef SIZE_MAX if (numb >= SIZE_MAX - sizeof (struct lalloc)) goto failure; -#endif if (ptr == NULL) { pp = (struct lalloc *)ap; @@ -46,9 +52,7 @@ aresize(void *ptr, size_t numb, Area *ap) lp = realloc(lp, numb + sizeof (struct lalloc)); } if (lp == NULL) { -#ifdef SIZE_MAX failure: -#endif internal_errorf("cannot allocate %lu data bytes", (unsigned long)numb); }