2 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
3 * Distributed under the terms of the MIT License.
12 strndup(const char* string
, size_t size
)
14 // While POSIX does not mention it, we handle NULL pointers gracefully
18 size_t length
= strlen(string
);
22 char* copied
= (char*)malloc(length
+ 1);
26 memcpy(copied
, string
, length
);
27 copied
[length
] = '\0';