Fossil SCM

Change fossil_malloc() so that it does not report "out of memory" when allocating zero bytes.

drh 2011-05-12 12:02 trunk
Commit 6b382b0818157da6a4e35ca7790a079891004a0b
1 file changed +1 -1
+1 -1
--- src/main.c
+++ src/main.c
@@ -403,11 +403,11 @@
403403
404404
/*
405405
** Malloc and free routines that cannot fail
406406
*/
407407
void *fossil_malloc(size_t n){
408
- void *p = malloc(n);
408
+ void *p = malloc(n==0 ? 1 : n);
409409
if( p==0 ) fossil_panic("out of memory");
410410
return p;
411411
}
412412
void fossil_free(void *p){
413413
free(p);
414414
--- src/main.c
+++ src/main.c
@@ -403,11 +403,11 @@
403
404 /*
405 ** Malloc and free routines that cannot fail
406 */
407 void *fossil_malloc(size_t n){
408 void *p = malloc(n);
409 if( p==0 ) fossil_panic("out of memory");
410 return p;
411 }
412 void fossil_free(void *p){
413 free(p);
414
--- src/main.c
+++ src/main.c
@@ -403,11 +403,11 @@
403
404 /*
405 ** Malloc and free routines that cannot fail
406 */
407 void *fossil_malloc(size_t n){
408 void *p = malloc(n==0 ? 1 : n);
409 if( p==0 ) fossil_panic("out of memory");
410 return p;
411 }
412 void fossil_free(void *p){
413 free(p);
414

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button