Last active
November 12, 2019 22:00
-
-
Save danielhams/9d25fc18eb771f0b4aaf5bf408dc4ee9 to your computer and use it in GitHub Desktop.
quick revs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef MYUID_IRIX_H | |
#define MYUID_IRIX_H | |
#include <string.h> | |
#include <config.h> | |
inline size_t strnlen (const char *string, size_t maxlen) | |
{ | |
const char *end = memchr (string, '\0', maxlen); | |
return end ? (size_t) (end - string) : maxlen; | |
} | |
inline char * strndup(char const *s, size_t n) | |
{ | |
size_t len = strnlen (s, n); | |
char *new = malloc (len + 1); | |
if (new == NULL) | |
return NULL; | |
new[len] = '\0'; | |
return memcpy (new, s, len); | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment