Implement the strdup function

Implement the strdup function as efficiently as you can..
How do you handle errors if you had to

How do you handle memory management here

strdup from pnetc libc code

char *
strdup (const char *s)
{
char *ns = (char *)malloc(strlen(s) + 1);
if (ns != 0)
{
strcpy (ns, s);
}
return ns;
}