Correct warning if used -Wextra

This commit is contained in:
german 2026-05-03 19:51:52 +04:00
parent fc6afeda5b
commit a4b5f36b3c
2 changed files with 8 additions and 0 deletions

BIN
argsparse

Binary file not shown.

View File

@ -109,6 +109,10 @@ void __free_string_array(char** arr, size_t size) {
static void* __sized_malloc(size_t size) { static void* __sized_malloc(size_t size) {
void* ptr = malloc(size); void* ptr = malloc(size);
if (ptr == NULL) {
puts("Out of memory!");
abort();
}
memset(ptr, ((int)(unsigned long)NULL), size); memset(ptr, ((int)(unsigned long)NULL), size);
return (void*)ptr; return (void*)ptr;
} }
@ -145,6 +149,10 @@ static unsigned char __compile_and_equals_sflag(char* flags, char* str) {
static char* malloc_str(char* str) { static char* malloc_str(char* str) {
char* ptr = (char*)malloc((strlen(str)) * sizeof(char) + sizeof(char)); char* ptr = (char*)malloc((strlen(str)) * sizeof(char) + sizeof(char));
if ((void*)ptr == NULL) {
puts("Out of memory!");
abort();
}
strcpy(ptr, str); strcpy(ptr, str);
return ptr; return ptr;
} }