created why2_recalloc fn in memory
deallocates and callocs
This commit is contained in:
parent
0e246be627
commit
c5394e63e5
@ -27,7 +27,8 @@ extern "C" {
|
|||||||
|
|
||||||
void *why2_malloc(unsigned long size);
|
void *why2_malloc(unsigned long size);
|
||||||
void *why2_calloc(unsigned long element, unsigned long size);
|
void *why2_calloc(unsigned long element, unsigned long size);
|
||||||
void *why2_realloc(void *pointer, unsigned long size);
|
void *why2_realloc(void *pointer, unsigned long size); //THIS DOESN'T PRESERVE CONTENT OF pointer!
|
||||||
|
void *why2_recalloc(void *pointer, unsigned long size, unsigned long block_size); //SAME AS why2_realloc BUT FILLS THE pointer WITH NULL-TERMS
|
||||||
|
|
||||||
char *why2_strdup(char *string);
|
char *why2_strdup(char *string);
|
||||||
|
|
||||||
|
@ -153,6 +153,17 @@ void *why2_realloc(void *pointer, unsigned long size)
|
|||||||
return allocated;
|
return allocated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *why2_recalloc(void *pointer, unsigned long size, unsigned long block_size)
|
||||||
|
{
|
||||||
|
if (pointer != NULL) why2_deallocate(pointer);
|
||||||
|
|
||||||
|
void *allocated = calloc(size, block_size);
|
||||||
|
|
||||||
|
push_to_list(allocated, ALLOCATION);
|
||||||
|
|
||||||
|
return allocated;
|
||||||
|
}
|
||||||
|
|
||||||
char *why2_strdup(char *string)
|
char *why2_strdup(char *string)
|
||||||
{
|
{
|
||||||
char *allocated = strdup(string);
|
char *allocated = strdup(string);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user