add heim_string_create_with_bytes

This commit is contained in:
Love Hörnquist Åstrand
2011-11-21 17:16:38 -08:00
parent 6ace66345b
commit 5a744a9ca6

View File

@@ -79,12 +79,19 @@ struct heim_type_data _heim_string_object = {
heim_string_t heim_string_t
heim_string_create(const char *string) heim_string_create(const char *string)
{ {
size_t len = strlen(string); return heim_string_create_with_bytes(string, strlen(string));
}
heim_string_t
heim_string_create_with_bytes(const void *data, size_t len)
{
heim_string_t s; heim_string_t s;
s = _heim_alloc_object(&_heim_string_object, len + 1); s = _heim_alloc_object(&_heim_string_object, len + 1);
if (s) if (s) {
memcpy(s, string, len + 1); memcpy(s, data, len);
((char *)s)[len] = '\0';
}
return s; return s;
} }