Writing malloc in C