aboutsummaryrefslogtreecommitdiff
path: root/ft_memalloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_memalloc.c')
-rw-r--r--ft_memalloc.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/ft_memalloc.c b/ft_memalloc.c
new file mode 100644
index 0000000..3c81f10
--- /dev/null
+++ b/ft_memalloc.c
@@ -0,0 +1,13 @@
+#include <stdlib.h>
+#include <string.h>
+
+void *ft_memalloc(size_t size)
+{
+ void *ptr;
+
+ if ((ptr = malloc(size)) == NULL)
+ return (NULL);
+ while (size-- > 0)
+ ((unsigned char*)ptr)[size] = 0;
+ return (ptr);
+}