oops; also add zero-allocator macro

This commit is contained in:
ryanfleury
2021-06-24 22:52:47 -06:00
parent a533b75ce4
commit 4b8d2c3ade
2 changed files with 7 additions and 4 deletions
+6 -1
View File
@@ -579,6 +579,11 @@ MD_FUNCTION void MD_MemoryCopy(void *dst, void *src, MD_u64 size);
MD_FUNCTION void* MD_AllocZero(MD_u64 size);
#define MD_PushArray(T,c) (T*)MD_AllocZero(sizeof(T)*(c))
// NOTE(rjf): Right now, both calls just automatically zero their memory,
// but I'm explicitly splitting this out to ensure that we don't accidentally
// assume that we have zeroed memory incorrectly in the future (when our
// allocation approach changes).
#define MD_PushArrayZero(T,c) (T*)MD_AllocZero(sizeof(T)*(c))
//~ Characters
MD_FUNCTION MD_b32 MD_CharIsAlpha(MD_u8 c);
@@ -664,7 +669,7 @@ MD_FUNCTION MD_MapSlot* MD_MapOverwrite(MD_Map *map, MD_MapKey key, void *val);
//~ Parsing
MD_FUNCTION_IMPL MD_NodeFlags MD_NodeFlagsFromTokenKind(MD_TokenKind kind);
MD_FUNCTION MD_NodeFlags MD_NodeFlagsFromTokenKind(MD_TokenKind kind);
MD_FUNCTION MD_b32 MD_TokenKindIsWhitespace(MD_TokenKind kind);
MD_FUNCTION MD_b32 MD_TokenKindIsComment(MD_TokenKind kind);
+1 -3
View File
@@ -942,9 +942,7 @@ MD_MapMakeBucketCount(MD_u64 bucket_count){
// make most sense with a parameter
MD_Map result = {0};
result.bucket_count = bucket_count;
// TODO(allen): push array zero
result.buckets = MD_PushArray(MD_MapBucket, bucket_count);
memset(result.buckets, 0, sizeof(*result.buckets)*bucket_count);
result.buckets = MD_PushArrayZero(MD_MapBucket, bucket_count);
return(result);
}