/*** * slice_tocstr.c */ #include #include #include #include "./slice.h" char * slice_tocstr(const struct slice s) { if (0 == s.ptr || 0 == s.size) { return 0x00; } char *str = malloc(s.size + 1); if (!str) { return 0x00; } memcpy(str, s.ptr, s.size); str[s.size] = '\0'; return str; }