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

Method AllocArray

NULLC/StdLib.cpp:341–360  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341NULLCArray NULLC::AllocArray(unsigned size, unsigned count, unsigned type)
342{
343 NULLCArray ret;
344 ret.len = 0;
345 ret.ptr = NULL;
346 if((unsigned long long)size * count > globalMemoryLimit)
347 {
348 nullcThrowError("ERROR: can't allocate array with %u elements of size %u", count, size);
349 return ret;
350 }
351 ret.len = 0;
352 ret.ptr = 4 + (char*)AllocObject(count * size + 4, type);
353 if(!(ret.ptr - 4))
354 return ret;
355 ((unsigned*)ret.ptr)[-1] = count;
356 markerType *marker = (markerType*)((char*)ret.ptr - 4 - sizeof(markerType));
357 *marker |= OBJECT_ARRAY;
358 ret.len = count;
359 return ret;
360}
361
362void NULLC::MarkMemory(unsigned int number)
363{

Callers

nothing calls this directly

Calls 1

nullcThrowErrorFunction · 0.70

Tested by

no test coverage detected