Switch to using calloc instead of malloc

This commit is contained in:
Abdelrahman Said
2024-03-24 11:25:52 +00:00
parent feada0b31c
commit 49ce26a6c2
2 changed files with 5 additions and 16 deletions

View File

@@ -15,15 +15,13 @@ struct dstr {
};
String *wapp_dstr_with_capacity(u64 capacity) {
String *out = (String *)malloc(sizeof(String) + capacity + 1);
String *out = (String *)calloc(1, sizeof(String) + capacity + 1);
if (!out) {
return NULL;
}
out->capacity = capacity;
out->size = 0;
memset(out->buf, 0, capacity + 1);
return out;
}