--- src/_pylibmcmodule.c.orig 2018-11-09 12:42:08.000000000 -0500 +++ src/_pylibmcmodule.c 2019-04-04 20:47:03.000000000 -0400 @@ -46,6 +46,25 @@ { Py_INCREF(obj); \ PyModule_AddObject(mod, nam, obj); } +/** + * Copy at most @p size characters from @p src, plus a terminating nul. + **/ +char *strndup(const char *src, size_t size); +char *strndup(const char *src, size_t size){ + size_t l = strlen(src); + char *r = NULL; + + if (l < size) + return strdup(src); + + r = (char *) malloc(size+1); + if (r == NULL) + return NULL; + + strncpy(r, src, size); + r[size] ='\0'; + return r; +} /* Some Python 3 porting stuff */ #ifndef Py_TYPE