4-variable-simplifier/string/new.c
2026-04-25 16:00:10 -04:00

27 lines
406 B
C

#include <debug.h>
#include "struct.h"
#include "new.h"
struct string* new_string(
const char* data_ro)
{
ENTER;
size_t len = strlen(data_ro);
char* data = malloc(len + 1);
memcpy(data, data_ro, len + 1);
struct string* this = smalloc(sizeof(*this));
this->data = data;
this->len = len;
this->refcount = 1;
EXIT;
return this;
}