mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-12 19:48:30 +08:00
Use const where possible
Reviewed By: IanChilds Differential Revision: D3741999 fbshipit-source-id: 1ba7da5784c3047f2d4c03746890192f724aa65e
This commit is contained in:
committed by
Facebook Github Bot 3
parent
50b0943c16
commit
25f2a26ce9
@@ -15,8 +15,8 @@ struct CSSNodeList {
|
||||
void **items;
|
||||
};
|
||||
|
||||
CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity) {
|
||||
CSSNodeListRef list = malloc(sizeof(struct CSSNodeList));
|
||||
CSSNodeListRef CSSNodeListNew(const uint32_t initialCapacity) {
|
||||
const CSSNodeListRef list = malloc(sizeof(struct CSSNodeList));
|
||||
CSS_ASSERT(list != NULL, "Could not allocate memory for list");
|
||||
|
||||
list->capacity = initialCapacity;
|
||||
@@ -27,20 +27,20 @@ CSSNodeListRef CSSNodeListNew(uint32_t initialCapacity) {
|
||||
return list;
|
||||
}
|
||||
|
||||
void CSSNodeListFree(CSSNodeListRef list) {
|
||||
void CSSNodeListFree(const CSSNodeListRef list) {
|
||||
free(list->items);
|
||||
free(list);
|
||||
}
|
||||
|
||||
uint32_t CSSNodeListCount(CSSNodeListRef list) {
|
||||
uint32_t CSSNodeListCount(const CSSNodeListRef list) {
|
||||
return list->count;
|
||||
}
|
||||
|
||||
void CSSNodeListAdd(CSSNodeListRef list, CSSNodeRef node) {
|
||||
void CSSNodeListAdd(const CSSNodeListRef list, const CSSNodeRef node) {
|
||||
CSSNodeListInsert(list, node, list->count);
|
||||
}
|
||||
|
||||
void CSSNodeListInsert(CSSNodeListRef list, CSSNodeRef node, uint32_t index) {
|
||||
void CSSNodeListInsert(const CSSNodeListRef list, const CSSNodeRef node, const uint32_t index) {
|
||||
if (list->count == list->capacity) {
|
||||
list->capacity *= 2;
|
||||
list->items = realloc(list->items, sizeof(void *) * list->capacity);
|
||||
@@ -55,8 +55,8 @@ void CSSNodeListInsert(CSSNodeListRef list, CSSNodeRef node, uint32_t index) {
|
||||
list->items[index] = node;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListRemove(CSSNodeListRef list, uint32_t index) {
|
||||
CSSNodeRef removed = list->items[index];
|
||||
CSSNodeRef CSSNodeListRemove(const CSSNodeListRef list, const uint32_t index) {
|
||||
const CSSNodeRef removed = list->items[index];
|
||||
list->items[index] = NULL;
|
||||
|
||||
for (uint32_t i = index; i < list->count - 1; i++) {
|
||||
@@ -68,7 +68,7 @@ CSSNodeRef CSSNodeListRemove(CSSNodeListRef list, uint32_t index) {
|
||||
return removed;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListDelete(CSSNodeListRef list, CSSNodeRef node) {
|
||||
CSSNodeRef CSSNodeListDelete(const CSSNodeListRef list, const CSSNodeRef node) {
|
||||
for (uint32_t i = 0; i < list->count; i++) {
|
||||
if (list->items[i] == node) {
|
||||
return CSSNodeListRemove(list, i);
|
||||
@@ -78,6 +78,6 @@ CSSNodeRef CSSNodeListDelete(CSSNodeListRef list, CSSNodeRef node) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CSSNodeRef CSSNodeListGet(CSSNodeListRef list, uint32_t index) {
|
||||
CSSNodeRef CSSNodeListGet(const CSSNodeListRef list, const uint32_t index) {
|
||||
return list->items[index];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user