Check out example codes for "void *malloc( size_t size ) { //do your stuf here return ::malloc(size); }". It will help you in understanding the concepts better.

Code Example 1

/* malloc example: random string generator*/
#include <stdio.h>      /* printf, scanf, NULL */
#include <stdlib.h>     /* malloc, free, rand */

int main ()
  int i,n;
  char * buffer;

  printf ("How long do you want the string? ");
  scanf ("%d", &i);

  buffer = (char*) malloc (i+1);
  if (buffer==NULL) exit (1);

  for (n=0; n<i; n++)

  printf ("Random string: %s\n",buffer);
  free (buffer);

  return 0;

Learn ReactJs, React Native from