// The global property structure is responsible for allocating the storage // method for script declared variables. Each allocation is independent of // other global properties, so that variables can be added and removed at // any time. void asCGlobalProperty::AllocateMemory() { if( type.GetSizeOnStackDWords() > 2 ) { memory = asNEWARRAY(asDWORD, type.GetSizeOnStackDWords()); memoryAllocated = true; } }
// The global property structure is responsible for allocating the storage // method for script declared variables. Each allocation is independent of // other global properties, so that variables can be added and removed at // any time. void asCGlobalProperty::AllocateMemory() { if( type.GetSizeOnStackDWords() > 2 ) { #ifndef WIP_16BYTE_ALIGNED memory = asNEWARRAY(asDWORD, type.GetSizeOnStackDWords()); #else // TODO: Avoid aligned allocation if not needed to reduce the waste of memory for the alignment memory = asNEWARRAYALIGNED(asDWORD, type.GetSizeOnStackDWords(), type.GetAlignment()); #endif memoryAllocated = true; } }
// internal asCGlobalProperty *asCModule::AllocateGlobalProperty(const char *name, const asCDataType &dt) { asCGlobalProperty *prop = asNEW(asCGlobalProperty); prop->index = (int)scriptGlobals.GetLength(); prop->name = name; prop->type = dt; scriptGlobals.PushLast(prop); // Allocate the memory for this property if( dt.GetSizeOnStackDWords() > 2 ) { prop->SetAddressOfValue(asNEWARRAY(asDWORD, dt.GetSizeOnStackDWords())); prop->memoryAllocated = true; } return prop; }
// interface void *asAllocMem(size_t size) { return asNEWARRAY(asBYTE, size); }