diff options
author | oharboe <oharboe> | 2008-06-15 18:49:31 +0000 |
---|---|---|
committer | oharboe <oharboe> | 2008-06-15 18:49:31 +0000 |
commit | d44d163fa0a43e3414214e13845b2be818b5c565 (patch) | |
tree | 3d48a1665435013ec599ad0cb6424e0ae0ab7e83 | |
parent | f2289af9733ae9625f5b2034b0d46fd258182bd7 (diff) | |
download | jimtcl-d44d163fa0a43e3414214e13845b2be818b5c565.zip jimtcl-d44d163fa0a43e3414214e13845b2be818b5c565.tar.gz jimtcl-d44d163fa0a43e3414214e13845b2be818b5c565.tar.bz2 |
* ChangeLog, jim.c: realloc/malloc(0) fix. Convert
realloc/malloc(0) => realloc/malloc(1) which has an
identical implementation, whereas realloc/malloc(0) is
ambigous. "string map {} {}" used to result in malloc(0)
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | jim.c | 14 |
2 files changed, 17 insertions, 4 deletions
@@ -1,3 +1,10 @@ +2008-06-15 oharboe + + * ChangeLog, jim.c: realloc/malloc(0) fix. Convert + realloc/malloc(0) => realloc/malloc(1) which has an + identical implementation, whereas realloc/malloc(0) is + ambigous. "string map {} {}" used to result in malloc(0) + 2008-06-13 oharboe * ChangeLog: Øyvind Harboe's first test as a committer. @@ -2,7 +2,7 @@ * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org> * Copyright 2005 Clemens Hintze <c.hintze@gmx.net> * - * $Id: jim.c,v 1.171 2007/01/31 00:49:05 patthoyts Exp $ + * $Id: jim.c,v 1.172 2008/06/15 18:49:31 oharboe Exp $ * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -494,9 +494,12 @@ void Jim_Panic(Jim_Interp *interp, const char *fmt, ...) void *Jim_Alloc(int size) { + /* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ + if (size==0) + size=1; void *p = malloc(size); if (p == NULL) - Jim_Panic(NULL,"Out of memory"); + Jim_Panic(NULL,"malloc: Out of memory"); return p; } @@ -506,9 +509,12 @@ void Jim_Free(void *ptr) { void *Jim_Realloc(void *ptr, int size) { + /* We allocate zero length arrayes, etc. to use a single orthogonal codepath */ + if (size==0) + size=1; void *p = realloc(ptr, size); if (p == NULL) - Jim_Panic(NULL,"Out of memory"); + Jim_Panic(NULL,"realloc: Out of memory"); return p; } @@ -11757,7 +11763,7 @@ int Jim_InteractivePrompt(Jim_Interp *interp) "Copyright (c) 2005 Salvatore Sanfilippo" JIM_NL, JIM_VERSION / 100, JIM_VERSION % 100); fprintf(interp->stdout_, - "CVS ID: $Id: jim.c,v 1.171 2007/01/31 00:49:05 patthoyts Exp $" + "CVS ID: $Id: jim.c,v 1.172 2008/06/15 18:49:31 oharboe Exp $" JIM_NL); Jim_SetVariableStrWithStr(interp, "jim_interactive", "1"); while (1) { |