Fossil SCM
Change fossil_malloc() so that it does not report "out of memory" when allocating zero bytes.
Commit
6b382b0818157da6a4e35ca7790a079891004a0b
Parent
dcc68b46b29a096…
1 file changed
+1
-1
+1
-1
| --- src/main.c | ||
| +++ src/main.c | ||
| @@ -403,11 +403,11 @@ | ||
| 403 | 403 | |
| 404 | 404 | /* |
| 405 | 405 | ** Malloc and free routines that cannot fail |
| 406 | 406 | */ |
| 407 | 407 | void *fossil_malloc(size_t n){ |
| 408 | - void *p = malloc(n); | |
| 408 | + void *p = malloc(n==0 ? 1 : n); | |
| 409 | 409 | if( p==0 ) fossil_panic("out of memory"); |
| 410 | 410 | return p; |
| 411 | 411 | } |
| 412 | 412 | void fossil_free(void *p){ |
| 413 | 413 | free(p); |
| 414 | 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); |
| 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 |