MCPcopy Create free account
hub / github.com/IoLanguage/io / UArray_setSize_

Function UArray_setSize_

libs/basekit/source/UArray.c:427–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

425// size
426
427void UArray_setSize_(UArray *self, size_t size) {
428 if (size != self->size) {
429 size_t oldSizeInBytes = UArray_sizeInBytes(self);
430 size_t newSizeInBytes = self->itemSize * size;
431
432#ifdef UARRAY_DEBUG
433 UArray_checkIfOkToRelloc(self);
434#endif
435 self->data = io_realloc(self->data, newSizeInBytes + 1);
436
437 self->data[newSizeInBytes] = 0x0;
438 self->size = size;
439
440 if (newSizeInBytes > oldSizeInBytes) {
441 memset(self->data + oldSizeInBytes, 0,
442 newSizeInBytes - oldSizeInBytes);
443 }
444
445 UArray_changed(self);
446 }
447}
448
449size_t UArray_size(const UArray *self) { return self->size; }
450

Callers 15

UArray_unescapeFunction · 0.85
UArray_duplicateIndexesFunction · 0.85
UArray_removeOddIndexesFunction · 0.85
UArray_removeEvenIndexesFunction · 0.85
BStream_emptyFunction · 0.85
UArray_fread_Function · 0.85
UArray_readFromCStream_Function · 0.85
Date_asStringFunction · 0.85

Calls 3

UArray_sizeInBytesFunction · 0.85
UArray_checkIfOkToRellocFunction · 0.85
UArray_changedFunction · 0.85

Tested by

no test coverage detected