- Decreased the required parameter count of VM_strcat to 1.
- Added a check to VM_strunzone so it wont free already freed strings and
thus crash the qc (only if developer != 0).
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4691
d7cf8633-e32d-0410-b094-
e92efae38249
{
char *s;
- if(prog->argc < 2)
- PRVM_ERROR("VM_strcat wrong parameter count (min. 2 expected ) !\n");
+ if(prog->argc < 1)
+ PRVM_ERROR("VM_strcat wrong parameter count (min. 1 expected ) !\n");
s = VM_GetTempString();
VM_VarString(0, s, VM_STRINGTEMP_LENGTH);
//void(string s) strunzone = #119; // removes a copy of a string from the string zone (you can not use that string again or it may crash!!!)
void VM_strunzone(void)
{
+ char *str;
VM_SAFEPARMCOUNT(1,VM_strunzone);
- Mem_Free(PRVM_G_STRING(OFS_PARM0));
+ str = PRVM_G_STRING(OFS_PARM0);
+ if( developer.integer && !Mem_IsAllocated( VM_STRINGS_MEMPOOL, str ) )
+ PRVM_ERROR( "VM_strunzone: Zone string already freed in %s!", PRVM_NAME );
+ else
+ Mem_Free( str );
}
/*
#endif
}
+qboolean Mem_IsAllocated(mempool_t *pool, void *data)
+{
+ memheader_t *header;
+ memheader_t *target;
+
+ target = (memheader_t *)((qbyte *) data - sizeof(memheader_t));
+ for( header = pool->chain ; header ; header = header->next )
+ if( header == target )
+ return true;
+ return false;
+}
+
+
// used for temporary memory allocations around the engine, not for longterm
// storage, if anything in this pool stays allocated during gameplay, it is
// considered a leak
void _Mem_EmptyPool(mempool_t *pool, const char *filename, int fileline);
void _Mem_CheckSentinels(void *data, const char *filename, int fileline);
void _Mem_CheckSentinelsGlobal(const char *filename, int fileline);
+qboolean Mem_IsAllocated(mempool_t *pool, void *data);
// used for temporary allocations
mempool_t *tempmempool;