5 #ifndef DYNAALLOCIMPL_H 6 #define DYNAALLOCIMPL_H 16 return reallocArray(
nullptr, 0, count);
20 if (newCount != oldCount || array ==
nullptr) {
22 if (array ==
nullptr) {
23 array =
new T[newCount];
24 memset((
void*)array, 0, newCount *
sizeof(T));
26 else if (newCount == 0) {
27 array = deleteArray(array);
30 T* newArray =
new T[newCount];
31 uint copyCount = newCount > oldCount ? oldCount : newCount;
32 memcpy(newArray, array, copyCount *
sizeof(T));
36 if (newCount > oldCount)
37 memset((array + oldCount), 0, (newCount - oldCount) *
sizeof(T));
40 catch (std::exception& e) {
53 memset((
void*)array, 0, count *
sizeof(T));
58 return reallocVect(
nullptr, 0, count,
true);
62 if (newCount != oldCount || array ==
nullptr) {
64 if (array ==
nullptr) {
65 array =
new T*[newCount];
66 memset(array, 0, newCount *
sizeof(T*));
68 else if (newCount == 0) {
69 array = deleteVect(array, oldCount, isOwner);
72 T** newArray =
new T*[newCount];
73 uint copyCount = newCount > oldCount ? oldCount : newCount;
74 memcpy(newArray, array, copyCount *
sizeof(T*));
75 if (isOwner && (newCount < oldCount)) {
79 for (uint idx = newCount; idx < oldCount; ++idx) {
88 memset(array, 0, oldCount *
sizeof(T*));
91 if (newCount > oldCount) {
92 memset((newArray + oldCount), 0, (newCount - oldCount) *
sizeof(T*));
97 catch (std::exception& e) {
105 for (uint idx = 0; idx < arrayCount; ++idx) {
109 memset(array, 0, arrayCount *
sizeof(T*));
119 #endif //DYNAALLOCIMPL_H Definition: DynaAlloc.h:13
static T * newArray(uint count)
Definition: DynaAllocImpl.h:15
static T ** deleteVect(T **array, uint arrayCount, bool isOwner)
Definition: DynaAllocImpl.h:103
static T * reallocArray(T *array, uint oldCount, uint newCount)
Definition: DynaAllocImpl.h:19
static T * deleteArray(T *array)
Definition: DynaAllocImpl.h:46
static T ** newVect(uint count)
Definition: DynaAllocImpl.h:57
static T ** reallocVect(T **array, uint oldCount, uint newCount, bool isOwner)
Definition: DynaAllocImpl.h:61
static T * clearArray(T *array, uint count)
Definition: DynaAllocImpl.h:52
Definition: DynaAlloc.h:26