Implement custom assert macro

Summary: assert.h assertion gets stripped from builds. I don't want these assertions to be stripped so implement a custom assert macro. This also allows the assertion to be documented with a message.

Reviewed By: javache

Differential Revision: D3648805

fbshipit-source-id: a6bf1bb55e1e0ee37284647ab76d66f3956a66c0
This commit is contained in:
Emil Sjolander
2016-08-02 08:07:11 -07:00
committed by Facebook Github Bot 7
parent ac44d2ea6e
commit 9689062f6c
4 changed files with 22 additions and 8 deletions

View File

@@ -17,12 +17,12 @@ struct CSSNodeList {
CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity) {
CSSNodeListRef list = malloc(sizeof(struct CSSNodeList));
assert(list != NULL);
CSS_ASSERT(list != NULL, "Could not allocate memory for list");
list->capacity = initialCapacity;
list->count = 0;
list->items = malloc(sizeof(void*) * list->capacity);
assert(list->items != NULL);
CSS_ASSERT(list->items != NULL, "Could not allocate memory for items");
return list;
}
@@ -43,7 +43,7 @@ void CSSNodeListInsert(CSSNodeListRef list, CSSNodeRef node, uint32_t index) {
if (list->count == list->capacity) {
list->capacity *= 2;
list->items = realloc(list->items, sizeof(void*) * list->capacity);
assert(list->items != NULL);
CSS_ASSERT(list->items != NULL, "Could not extend allocation for items");
}
for (uint32_t i = list->count; i > index; i--) {