Skip to content

Instantly share code, notes, and snippets.

@ayaderaghul
Created April 20, 2018 09:30
Show Gist options
  • Save ayaderaghul/2390d965700decffa14cc3aab24ee6e0 to your computer and use it in GitHub Desktop.
Save ayaderaghul/2390d965700decffa14cc3aab24ee6e0 to your computer and use it in GitHub Desktop.
#include <stdlib.h>
void *ft_memalloc(size_t size)
{
char *tab;
size_t i;
tab = (char *)malloc(sizeof(char) * (size + 1));
if (tab == NULL)
return (tab);
i = 0;
while (i < size)
tab[i++] = 0;
tab[i] = 0;
return (tab);
}
@pgiammel
Copy link

#include <stdlib.h>

void	*ft_memalloc(size_t size)
{
	char    *tab;
	size_t  i;

	tab = (char *)malloc(sizeof(char) * size);
	if (tab == NULL)
		return (tab);
	i = 0;
	while (i < size)
		tab[i++] = 0;
	return (tab);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment