Switch to using calloc instead of malloc
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user