MCPcopy Create free account
hub / github.com/LabSound/LabSound / allocate

Method allocate

include/LabSound/core/AudioArray.h:40–60  ·  view source on GitHub ↗

allocation will realloc if necessary. the buffer will be zeroed whether reallocated or not

Source from the content-addressed store, hash-verified

38 // the buffer will be zeroed whether reallocated or not
39 //
40 void allocate(int n)
41 {
42 const uintptr_t alignment = 0x10;
43 const uintptr_t mask = ~0xf;
44 size_t initialSize = sizeof(T) * n + alignment;
45 if (_size != n) {
46 if (_allocation)
47 free(_allocation);
48
49 if (n) {
50 _allocation = static_cast<T*>(calloc(initialSize, 1));
51 _data = (T*)((((intptr_t)_allocation) + (alignment-1)) & mask);
52 }
53 else {
54 _allocation = nullptr;
55 _data = nullptr;
56 }
57
58 _size = n;
59 }
60 }
61
62 T * data() { return _data; }
63 const T * data() const { return _data; }

Callers 5

processPolyBLEPMethod · 0.80
RealtimeAnalyserMethod · 0.80
setFftSizeMethod · 0.80
process_oscillatorMethod · 0.80
DelayDSPKernelMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected