MCPcopy Create free account
hub / github.com/WheretIB/nullc / grow

Method grow

NULLC/Array.h:121–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119 }
120
121 __inline void grow(unsigned int newSize)
122 {
123 if(max + (max >> 1) > newSize)
124 newSize = max + (max >> 1);
125 else
126 newSize += 32;
127 T* newData;
128 if(!skipConstructor)
129 newData = NULLC::construct<T>(newSize);
130 else
131 newData = (T*)NULLC::alignedAlloc(sizeof(T) * newSize);
132 assert(newData);
133 if(zeroNewMemory)
134 memset(newData, 0, newSize * sizeof(T));
135 memcpy(newData, data, max * sizeof(T));
136 if(data != &one)
137 {
138 if(!skipConstructor)
139 NULLC::destruct(data, max);
140 else
141 NULLC::alignedDealloc(data);
142 }
143 data = newData;
144 max = newSize;
145 }
146 T *data;
147 T one;
148 unsigned int max, count;

Callers 1

TranslateToNativeMethod · 0.45

Calls 2

assertFunction · 0.85
destructFunction · 0.85

Tested by

no test coverage detected