Created
November 18, 2011 21:15
-
-
Save yaymukund/1377779 to your computer and use it in GitHub Desktop.
Patch for installing pylibmc
This file contains 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
--- _pylibmcmodule.c.old»···2011-11-18 13:10:03.000000000 -0800 | |
+++ _pylibmcmodule.c»···2011-11-18 02:51:05.000000000 -0800 | |
@@ -45,6 +45,26 @@ | |
#define PyModule_ADD_REF(mod, nam, obj) \ | |
{ Py_INCREF(obj); \ | |
PyModule_AddObject(mod, nam, obj); } | |
+size_t | |
+strnlen(const char *s, size_t maxlen) | |
+{ | |
+ const char * eospos; | |
+ eospos = memchr(s, (int)'\0', maxlen); | |
+ return (eospos == NULL ? maxlen : (size_t)(eospos-s)); | |
+} | |
+ | |
+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); | |
+} | |
· | |
/* {{{ Type methods */ | |
static PylibMC_Client *PylibMC_ClientType_new(PyTypeObject *type, |
This file contains 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
--- _pylibmcmodule.c.old»···2011-11-18 13:10:03.000000000 -0800 | |
+++ _pylibmcmodule.c»···2011-11-18 02:51:05.000000000 -0800 | |
@@ -45,6 +45,26 @@ | |
#define PyModule_ADD_REF(mod, nam, obj) \ | |
{ Py_INCREF(obj); \ | |
PyModule_AddObject(mod, nam, obj); } | |
+size_t | |
+strnlen(const char *s, size_t maxlen) | |
+{ | |
+ const char * eospos; | |
+ eospos = memchr(s, (int)'\0', maxlen); | |
+ return (eospos == NULL ? maxlen : (size_t)(eospos-s)); | |
+} | |
+ | |
+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); | |
+} | |
· | |
/* {{{ Type methods */ | |
static PylibMC_Client *PylibMC_ClientType_new(PyTypeObject *type, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment