Overview
Context
Changes
Modified src/OFObject.h
from [9d5edd8a16]
to [19b99027a7].
︙ | | |
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
|
827
828
829
830
831
832
833
834
835
836
837
838
839
840
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
* @param count The number of items to allocate
* @return A pointer to the allocated memory. May return NULL if the specified
* size or count is 0.
*/
- (nullable void *)allocMemoryWithSize: (size_t)size
count: (size_t)count OF_WARN_UNUSED_RESULT;
/**
* @brief Allocates memory, initializes it with zeros and stores it in the
* object's memory pool.
*
* It will be free'd automatically when the object is deallocated.
*
* @param size The size of the memory to allocate
* @return A pointer to the allocated memory. May return NULL if the specified
* size is 0.
*/
- (nullable void *)allocZeroedMemoryWithSize: (size_t)size
OF_WARN_UNUSED_RESULT;
/**
* @brief Allocates memory for the specified number of items, initializes it
* with zeros and stores it in the object's memory pool.
*
* It will be free'd automatically when the object is deallocated.
*
* @param size The size of each item to allocate
* @param count The number of items to allocate
* @return A pointer to the allocated memory. May return NULL if the specified
* size or count is 0.
*/
- (nullable void *)allocZeroedMemoryWithSize: (size_t)size
count: (size_t)count
OF_WARN_UNUSED_RESULT;
/**
* @brief Resizes memory in the object's memory pool to the specified size.
*
* If the pointer is NULL, this is equivalent to allocating memory.
* If the size is 0, this is equivalent to freeing memory.
*
* @param pointer A pointer to the already allocated memory
|
︙ | | |
Modified src/OFObject.m
from [2cf6c520ad]
to [b6169ba098].
︙ | | |
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
|
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
{
if OF_UNLIKELY (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exception];
return [self allocMemoryWithSize: size * count];
}
- (void *)allocZeroedMemoryWithSize: (size_t)size
{
void *pointer;
struct pre_mem *preMem;
if OF_UNLIKELY (size == 0)
return NULL;
if OF_UNLIKELY (size > SIZE_MAX - PRE_IVARS_ALIGN)
@throw [OFOutOfRangeException exception];
if OF_UNLIKELY ((pointer = calloc(1, PRE_MEM_ALIGN + size)) == NULL)
@throw [OFOutOfMemoryException
exceptionWithRequestedSize: size];
preMem = pointer;
preMem->owner = self;
preMem->prev = PRE_IVARS->lastMem;
if OF_LIKELY (PRE_IVARS->lastMem != NULL)
PRE_IVARS->lastMem->next = preMem;
if OF_UNLIKELY (PRE_IVARS->firstMem == NULL)
PRE_IVARS->firstMem = preMem;
PRE_IVARS->lastMem = preMem;
return (char *)pointer + PRE_MEM_ALIGN;
}
- (void *)allocZeroedMemoryWithSize: (size_t)size
count: (size_t)count
{
if OF_UNLIKELY (count > SIZE_MAX / size)
@throw [OFOutOfRangeException exception];
return [self allocZeroedMemoryWithSize: size * count];
}
- (void *)resizeMemory: (void *)pointer
size: (size_t)size
{
void *new;
struct pre_mem *preMem;
if OF_UNLIKELY (pointer == NULL)
|
︙ | | |