Created
April 11, 2026 07:23
-
-
Save kraj/3bce973d0842c98ff7607e8f5d7cd5a9 to your computer and use it in GitHub Desktop.
stdin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/sd/malloc.c b/src/sd/malloc.c | |
| index 7d241ad..43dd460 100644 | |
| --- a/src/sd/malloc.c | |
| +++ b/src/sd/malloc.c | |
| @@ -41,8 +41,7 @@ typedef void (*sd_malloc_handler_t)(); | |
| static sd_malloc_handler_t handler = NULL; | |
| static void * | |
| -fixup_null_alloc (n) | |
| - size_t n; | |
| +fixup_null_alloc (size_t n) | |
| { | |
| void* p = 0; | |
| @@ -62,8 +61,8 @@ fixup_null_alloc (n) | |
| allocated = (char *) sbrk (0) - (char *) &environ; | |
| sd_error("\nCannot allocate %lu bytes after allocating %lu bytes\n", | |
| (unsigned long) n, (unsigned long) allocated); | |
| - | |
| - if (handler) | |
| + | |
| + if (handler) | |
| handler(); | |
| else { | |
| sd_error("\n\tMemory exhausted !! Aborting.\n"); | |
| @@ -75,8 +74,7 @@ fixup_null_alloc (n) | |
| } | |
| sd_malloc_handler_t | |
| -sd_malloc_set_handler(a_handler) | |
| - sd_malloc_handler_t a_handler; | |
| +sd_malloc_set_handler(sd_malloc_handler_t a_handler) | |
| { | |
| sd_malloc_handler_t previous = handler; | |
| @@ -87,8 +85,7 @@ sd_malloc_set_handler(a_handler) | |
| /* Allocate N bytes of memory dynamically, with error checking. */ | |
| void * | |
| -sd_malloc (n) | |
| - size_t n; | |
| +sd_malloc (size_t n) | |
| { | |
| void *p; | |
| @@ -101,8 +98,7 @@ sd_malloc (n) | |
| /* Allocate memory for N elements of S bytes, with error checking. */ | |
| void * | |
| -sd_calloc (n, s) | |
| - size_t n, s; | |
| +sd_calloc (size_t n, size_t s) | |
| { | |
| void *p; | |
| @@ -117,9 +113,7 @@ sd_calloc (n, s) | |
| If P is NULL, run sd_malloc. */ | |
| void * | |
| -sd_realloc (p, n) | |
| - void *p; | |
| - size_t n; | |
| +sd_realloc (void *p, size_t n) | |
| { | |
| if (p == 0) | |
| return sd_malloc (n); | |
| @@ -132,8 +126,7 @@ sd_realloc (p, n) | |
| /* Return a newly allocated copy of STRING. */ | |
| char * | |
| -sd_strdup (string) | |
| - const char *string; | |
| +sd_strdup (const char *string) | |
| { | |
| return strcpy (sd_malloc (strlen (string) + 1), string); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment