summaryrefslogtreecommitdiffstats
path: root/avahi-common/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'avahi-common/malloc.c')
-rw-r--r--avahi-common/malloc.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/avahi-common/malloc.c b/avahi-common/malloc.c
index 018a0c0..9b0e22e 100644
--- a/avahi-common/malloc.c
+++ b/avahi-common/malloc.c
@@ -169,16 +169,16 @@ char *avahi_strdup(const char *s) {
char *avahi_strndup(const char *s, size_t max) {
char *r;
size_t size;
+ const char *p;
if (!s)
return NULL;
- size = strlen(s);
-
- if (size > max)
- size = max;
+ for (p = s, size = 0;
+ size < max && *p;
+ p++, size++);
- if (!(r = avahi_malloc(size+1)))
+ if (!(r = avahi_new(char, size+1)))
return NULL;
memcpy(r, s, size);