Implement the strstr function

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

Implement the strstr function

char *
strstr (const char *haystack, const char *needle)
{
char *result = (char *)NULL;

if ((haystack != (char *)NULL) && (needle != (char *)NULL))
{
register int i;
int hl = strlen (haystack);
int nl = strlen (needle);

for (i = 0; i < (hl - nl); i++)
if (strncmp (haystack + i, needle, nl) == 0)
{
result = haystack + i;
break;
}
}

return (result);
}