Esempio n. 1
0
asCString::~asCString()
{
	if( length > 11 && dynamic )
	{
		asDELETEARRAY(dynamic);
	}
}
Esempio n. 2
0
asCScriptCode::~asCScriptCode()
{
    if( !sharedCode && code )
    {
        asDELETEARRAY(code);
    }
}
Esempio n. 3
0
void asCString::Allocate(size_t len, bool keepData)
{
	// If we stored the capacity of the dynamically allocated buffer it would be possible
	// to save some memory allocations if a string decreases in size then increases again,
	// but this would require extra bytes in the string object itself, or a decrease of 
	// the static buffer, which in turn would mean extra memory is needed. I've tested each
	// of these options, and it turned out that the current choice is what best balanced
	// the number of allocations against the size of the allocations.

	if( len > 11 && len > length )
	{
		// Allocate a new dynamic buffer if the new one is larger than the old
		char *buf = asNEWARRAY(char,len+1);

		if( keepData )
		{
			int l = (int)len < (int)length ? (int)len : (int)length;
			memcpy(buf, AddressOf(), l);
		}

		if( length > 11 )
		{
			asDELETEARRAY(dynamic);
		}

		dynamic = buf;
	}
Esempio n. 4
0
asCGlobalProperty::~asCGlobalProperty()
{ 
#ifndef WIP_16BYTE_ALIGNED
	if( memoryAllocated ) { asDELETEARRAY(memory); } 
#else
	if( memoryAllocated ) { asDELETEARRAYALIGNED(memory); } 
#endif

	if( initFunc )
		initFunc->ReleaseInternal();
}
void asCString::Allocate(size_t len, bool keepData)
{
    if( len > 11 )
    {
        char *buf = asNEWARRAY(char,len+1);

        if( keepData )
        {
            int l = (int)len < (int)length ? (int)len : (int)length;
            memcpy(buf, AddressOf(), l);
        }

        if( length > 11 )
        {
            asDELETEARRAY(dynamic);
        }

        dynamic = buf;
    }
Esempio n. 6
0
int asCScriptCode::SetCode(const char *name, const char *code, size_t length, bool makeCopy)
{
	if( !code ) return asINVALID_ARG;
	this->name = name ? name : "";
	if( !sharedCode && this->code )
		asDELETEARRAY(this->code);

	if( length == 0 )
		length = strlen(code);
	if( makeCopy )
	{
		codeLength = length;
		sharedCode = false;
		this->code = asNEWARRAY(char,length);
		if( this->code == 0 )
			return asOUT_OF_MEMORY;
		memcpy((char*)this->code, code, length);
	}
	else
	{
Esempio n. 7
0
asCGlobalProperty::~asCGlobalProperty()
{ 
	if( memoryAllocated ) { asDELETEARRAY(memory); } 
	if( initFunc )
		initFunc->Release();
}
Esempio n. 8
0
// interface
void asFreeMem(void *mem)
{
	asDELETEARRAY(mem);
}