summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-10-24 02:22:56 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2021-10-24 02:22:56 +0200
commit7de5b52faa43f32959d3ce38ed03db0a2c21c715 (patch)
tree29de6efa43cc909072781672ffc85c366cf67e4b
parentbea2c98a066f217e0392c29b5c9edc60929944e7 (diff)
Use memset(3) on calloc(3)
-rw-r--r--libpsx/src/memory.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/libpsx/src/memory.c b/libpsx/src/memory.c
index 1d0e6de..3c63dc7 100644
--- a/libpsx/src/memory.c
+++ b/libpsx/src/memory.c
@@ -115,14 +115,9 @@ malloc_keep_finding:
void *calloc(size_t number, size_t size)
{
void *ptr = malloc(number * size);
- unsigned char *cptr = (unsigned char*)ptr;
- int x;
-
- if(ptr == NULL)
- ptr = NULL;
- for(x = 0; x < (number * size); x++)
- cptr[x] = 0;
+ if (ptr)
+ memset(ptr, 0, number * size);
return ptr;
}