MCPcopy Create free account
hub / github.com/AOMediaCodec/libavif / avifArrayCreate

Function avifArrayCreate

src/utils.c:87–106  ·  view source on GitHub ↗

On error, this function must set arr->ptr to NULL and both arr->count and arr->capacity to 0.

Source from the content-addressed store, hash-verified

85
86// On error, this function must set arr->ptr to NULL and both arr->count and arr->capacity to 0.
87avifBool avifArrayCreate(void * arrayStruct, uint32_t elementSize, uint32_t initialCapacity)
88{
89 avifArrayInternal * arr = (avifArrayInternal *)arrayStruct;
90 arr->elementSize = elementSize ? elementSize : 1;
91 arr->count = 0;
92 arr->capacity = initialCapacity;
93 if (arr->capacity > SIZE_MAX / arr->elementSize) {
94 arr->ptr = NULL;
95 arr->capacity = 0;
96 return AVIF_FALSE;
97 }
98 size_t byteCount = (size_t)arr->elementSize * arr->capacity;
99 arr->ptr = (uint8_t *)avifAlloc(byteCount);
100 if (!arr->ptr) {
101 arr->capacity = 0;
102 return AVIF_FALSE;
103 }
104 memset(arr->ptr, 0, byteCount);
105 return AVIF_TRUE;
106}
107
108void * avifArrayPush(void * arrayStruct)
109{

Callers 15

avifImageApplyOperationsFunction · 0.85
avifEncoderDataCreateFunction · 0.85
avifEncoderFinishFunction · 0.85
avifSampleTableCreateFunction · 0.85
avifMetaCreateFunction · 0.85
avifMetaFindOrCreateItemFunction · 0.85

Calls 1

avifAllocFunction · 0.85

Tested by

no test coverage detected