Switch to using calloc instead of malloc
This commit is contained in:
1 parent
feada0b31c
commit
49ce26a6c2
2 files changed
+5
-16
No files matched your search
+1
-3
@@ -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