diff options
Diffstat (limited to 'audio/libcanberra/files/patch-src_malloc.h')
-rw-r--r-- | audio/libcanberra/files/patch-src_malloc.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/audio/libcanberra/files/patch-src_malloc.h b/audio/libcanberra/files/patch-src_malloc.h new file mode 100644 index 000000000..58efa3096 --- /dev/null +++ b/audio/libcanberra/files/patch-src_malloc.h @@ -0,0 +1,35 @@ +--- src/malloc.h.orig 2008-06-10 10:42:46.000000000 -0400 ++++ src/malloc.h 2008-08-05 23:34:40.000000000 -0400 +@@ -31,6 +31,32 @@ + #define ca_free free + #define ca_malloc0(size) calloc(1, (size)) + #define ca_strdup strdup ++#ifdef __FreeBSD__ ++static inline char *strndup (const char *s, size_t n) ++{ ++ size_t nAvail; ++ char *p; ++ ++ if (!s) { ++ return NULL; ++ } ++ ++ if (memchr (s, '\0', n) != NULL) { ++ nAvail = strlen (s); ++ if (nAvail > n) ++ nAvail = n; ++ } else { ++ nAvail = n; ++ } ++ p = ca_malloc (nAvail + 1); ++ if (p == NULL) ++ return NULL; ++ memcpy (p, s, nAvail); ++ p[nAvail] = '\0'; ++ ++ return p; ++} ++#endif + #define ca_strndup strndup + + void* ca_memdup(const void* p, size_t size); |