| 246 | } |
| 247 | |
| 248 | void* NULLC::AllocObject(int size, unsigned type) |
| 249 | { |
| 250 | if(size < 0) |
| 251 | { |
| 252 | nullcThrowError("ERROR: requested memory size is less than zero"); |
| 253 | return NULL; |
| 254 | } |
| 255 | void *data = NULL; |
| 256 | size += sizeof(markerType); |
| 257 | |
| 258 | if((unsigned int)(usedMemory + size) > globalMemoryLimit) |
| 259 | { |
| 260 | CollectMemory(); |
| 261 | if((unsigned int)(usedMemory + size) > globalMemoryLimit) |
| 262 | { |
| 263 | nullcThrowError("ERROR: reached global memory maximum"); |
| 264 | return NULL; |
| 265 | } |
| 266 | }else if((unsigned int)(usedMemory + size) > collectableMinimum){ |
| 267 | CollectMemory(); |
| 268 | } |
| 269 | unsigned int realSize = size; |
| 270 | if(size <= 64) |
| 271 | { |
| 272 | if(size <= 16) |
| 273 | { |
| 274 | if(size <= 8) |
| 275 | { |
| 276 | data = pool8.Alloc(); |
| 277 | realSize = 8; |
| 278 | }else{ |
| 279 | data = pool16.Alloc(); |
| 280 | realSize = 16; |
| 281 | } |
| 282 | }else{ |
| 283 | if(size <= 32) |
| 284 | { |
| 285 | data = pool32.Alloc(); |
| 286 | realSize = 32; |
| 287 | }else{ |
| 288 | data = pool64.Alloc(); |
| 289 | realSize = 64; |
| 290 | } |
| 291 | } |
| 292 | }else{ |
| 293 | if(size <= 256) |
| 294 | { |
| 295 | if(size <= 128) |
| 296 | { |
| 297 | data = pool128.Alloc(); |
| 298 | realSize = 128; |
| 299 | }else{ |
| 300 | data = pool256.Alloc(); |
| 301 | realSize = 256; |
| 302 | } |
| 303 | }else{ |
| 304 | if(size <= 512) |
| 305 | { |
nothing calls this directly
no test coverage detected