| 106 | } |
| 107 | |
| 108 | void * avifArrayPush(void * arrayStruct) |
| 109 | { |
| 110 | avifArrayInternal * arr = (avifArrayInternal *)arrayStruct; |
| 111 | if (arr->count == arr->capacity) { |
| 112 | uint8_t * oldPtr = arr->ptr; |
| 113 | size_t oldByteCount = (size_t)arr->elementSize * arr->capacity; |
| 114 | if (oldByteCount > SIZE_MAX / 2 || arr->capacity > UINT32_MAX / 2) { |
| 115 | return NULL; |
| 116 | } |
| 117 | size_t newByteCount = oldByteCount * 2; |
| 118 | uint8_t * newPtr = (uint8_t *)avifAlloc(newByteCount); |
| 119 | if (newPtr == NULL) { |
| 120 | return NULL; |
| 121 | } |
| 122 | arr->ptr = newPtr; |
| 123 | memset(arr->ptr + oldByteCount, 0, oldByteCount); |
| 124 | memcpy(arr->ptr, oldPtr, oldByteCount); |
| 125 | arr->capacity *= 2; |
| 126 | avifFree(oldPtr); |
| 127 | } |
| 128 | ++arr->count; |
| 129 | return &arr->ptr[(arr->count - 1) * (size_t)arr->elementSize]; |
| 130 | } |
| 131 | |
| 132 | void avifArrayPop(void * arrayStruct) |
| 133 | { |
no test coverage detected