Skip to content

Instantly share code, notes, and snippets.

@ldx
Created June 3, 2016 16:54
Show Gist options
  • Save ldx/61416c9a9cc1f0bf147d10e7e6ef7954 to your computer and use it in GitHub Desktop.
Save ldx/61416c9a9cc1f0bf147d10e7e6ef7954 to your computer and use it in GitHub Desktop.
char *jsonp_strndup(const char *str, size_t len)
{
char *new_str;
new_str = jsonp_malloc(len + 1);
if(!new_str)
return NULL;
memcpy(new_str, str, len);
new_str[len] = '\0';
return new_str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment