Modified to fix memory leaks and improve speed
This commit is contained in:
		@@ -24,12 +24,11 @@ void OnAmxxAttach( void )
 | 
			
		||||
 | 
			
		||||
	MF_AddNatives(map_exports);
 | 
			
		||||
	MF_AddNatives(map_creation_exports);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void OnAmxxDetach( void )
 | 
			
		||||
{
 | 
			
		||||
	MasterTrie.Clear();
 | 
			
		||||
	MasterList.Clear();
 | 
			
		||||
	MasterMap.Clear();
 | 
			
		||||
	JudyClearMasterTrie(&MasterTrie);
 | 
			
		||||
	JudyClearMasterList(&MasterList);
 | 
			
		||||
	JudyClearMasterMap(&MasterMap);
 | 
			
		||||
}
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							@@ -6,22 +6,7 @@
 | 
			
		||||
--------------------Configuration: Array - Win32 Release--------------------
 | 
			
		||||
</h3>
 | 
			
		||||
<h3>Command Lines</h3>
 | 
			
		||||
Creating temporary file "C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC49.tmp" with contents
 | 
			
		||||
[
 | 
			
		||||
/nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "ARRAY_EXPORTS" /FR"Release/" /Fp"Release/Array.pch" /YX /Fo"Release/" /Fd"Release/" /FD /c 
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\Array.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\BinTrieNatives.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\Capsule.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\CArray.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\CBinTrie.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\CKeytable.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\ListNatives.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\MapNatives.cpp"
 | 
			
		||||
"C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\amxxmodule.cpp"
 | 
			
		||||
]
 | 
			
		||||
Creating command line "cl.exe @C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC49.tmp" 
 | 
			
		||||
Creating temporary file "C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC4A.tmp" with contents
 | 
			
		||||
Creating temporary file "C:\DOCUME~1\Edward\LOCALS~1\Temp\RSP36D.tmp" with contents
 | 
			
		||||
[
 | 
			
		||||
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /incremental:no /pdb:"Release/Array.pdb" /machine:I386 /out:"Release/Array.dll" /implib:"Release/Array.lib" 
 | 
			
		||||
".\Release\Array.obj"
 | 
			
		||||
@@ -36,61 +21,16 @@ kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32
 | 
			
		||||
".\Release\amxxmodule.obj"
 | 
			
		||||
".\Judy.lib"
 | 
			
		||||
]
 | 
			
		||||
Creating command line "link.exe @C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC4A.tmp"
 | 
			
		||||
Creating command line "link.exe @C:\DOCUME~1\Edward\LOCALS~1\Temp\RSP36D.tmp"
 | 
			
		||||
<h3>Output Window</h3>
 | 
			
		||||
Compiling...
 | 
			
		||||
Array.cpp
 | 
			
		||||
BinTrieNatives.cpp
 | 
			
		||||
Capsule.cpp
 | 
			
		||||
CArray.cpp
 | 
			
		||||
CBinTrie.cpp
 | 
			
		||||
CKeytable.cpp
 | 
			
		||||
JudyExtra.cpp
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(8) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(15) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(40) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(75) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(80) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(83) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(103) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(107) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(110) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(133) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(147) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(152) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(155) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(170) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(178) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(186) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(189) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
C:\Documents and Settings\Edward\Desktop\module\Judy Test\Array\JudyExtra.cpp(217) : warning C4101: 'e' : unreferenced local variable
 | 
			
		||||
ListNatives.cpp
 | 
			
		||||
MapNatives.cpp
 | 
			
		||||
amxxmodule.cpp
 | 
			
		||||
Linking...
 | 
			
		||||
   Creating library Release/Array.lib and object Release/Array.exp
 | 
			
		||||
LINK : warning LNK4098: defaultlib "LIBC" conflicts with use of other libs; use /NODEFAULTLIB:library
 | 
			
		||||
Creating temporary file "C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC4E.tmp" with contents
 | 
			
		||||
[
 | 
			
		||||
/nologo /o"Release/Array.bsc" 
 | 
			
		||||
".\Release\Array.sbr"
 | 
			
		||||
".\Release\BinTrieNatives.sbr"
 | 
			
		||||
".\Release\Capsule.sbr"
 | 
			
		||||
".\Release\CArray.sbr"
 | 
			
		||||
".\Release\CBinTrie.sbr"
 | 
			
		||||
".\Release\CKeytable.sbr"
 | 
			
		||||
".\Release\JudyExtra.sbr"
 | 
			
		||||
".\Release\ListNatives.sbr"
 | 
			
		||||
".\Release\MapNatives.sbr"
 | 
			
		||||
".\Release\amxxmodule.sbr"]
 | 
			
		||||
Creating command line "bscmake.exe @C:\DOCUME~1\Edward\LOCALS~1\Temp\RSPC4E.tmp"
 | 
			
		||||
Creating browse info file...
 | 
			
		||||
<h3>Output Window</h3>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
<h3>Results</h3>
 | 
			
		||||
Array.dll - 0 error(s), 19 warning(s)
 | 
			
		||||
Array.dll - 0 error(s), 1 warning(s)
 | 
			
		||||
</pre>
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
@@ -48,8 +48,7 @@
 | 
			
		||||
#define JUDY_SLAVE_ISEMPTY_FUNC		JUDY_GLUE_FUNC( bintrie ,	_isempty	)
 | 
			
		||||
#define JUDY_SLAVE_ISEMPTY_STR		JUDY_GLUE_STR (	bintrie ,	_isempty	)
 | 
			
		||||
 | 
			
		||||
#define JUDY_SLAVE_REMOVE_FUNC		JUDY_GLUE_FUNC( bintrie ,	_remove		)
 | 
			
		||||
#define JUDY_SLAVE_REMOVE_STR		JUDY_GLUE_STR (	bintrie ,	_remove		)
 | 
			
		||||
#define NO_JUDY_SLAVE_REMOVE_FUNC
 | 
			
		||||
 | 
			
		||||
#define JUDY_SLAVE_SEARCH_FUNCTIONS
 | 
			
		||||
#define JUDY_SLAVE_FIRST_FUNC		JUDY_GLUE_FUNC( bintrie ,	_first		)
 | 
			
		||||
 
 | 
			
		||||
@@ -46,12 +46,24 @@ static cell AMX_NATIVE_CALL bintrie_get(AMX *amx,cell *params)
 | 
			
		||||
	JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave Get Function ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static cell AMX_NATIVE_CALL bintrie_remove(AMX *amx,cell *params)
 | 
			
		||||
{
 | 
			
		||||
	DTYPE* Unit = NULL;
 | 
			
		||||
 | 
			
		||||
	JUDY_GET_INDEX(MNAME,Unit, params[1]);
 | 
			
		||||
	ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
		
 | 
			
		||||
	try { return Unit->Delete(Indice ); }
 | 
			
		||||
	JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave Delete Function ");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
AMX_NATIVE_INFO bintrie_usage_exports[] = 
 | 
			
		||||
{
 | 
			
		||||
	{ "bintrie_create", bintrie_create },
 | 
			
		||||
	{ "bintrie_set", bintrie_set },
 | 
			
		||||
	{ "bintrie_get", bintrie_get },
 | 
			
		||||
	{ "bintrie_remove", bintrie_remove },
 | 
			
		||||
 | 
			
		||||
	{ NULL, NULL }
 | 
			
		||||
};
 | 
			
		||||
@@ -16,12 +16,13 @@ private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	Array()					{ Table = NULL; }
 | 
			
		||||
	~Array()				{ Clear(); }
 | 
			
		||||
	~Array()				{ Clear();		}
 | 
			
		||||
	void Remove()			{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()			{ JudyClearList(this); return JudyLFreeArray(&Table, PJE0); }
 | 
			
		||||
	Word_t MemoryUsed()		{ return JudyLMemUsed(Table); }
 | 
			
		||||
 | 
			
		||||
	int Delete(cell Key)	{ delete Get(Key,true); return JudyLDel(&Table, Key, PJE0 ); }
 | 
			
		||||
	int Delete(cell Key)	{ return JudyLDel(&Table, Key, PJE0 ); }
 | 
			
		||||
 | 
			
		||||
	void Set(cell Index, Pvoid_t value, bool disable_check) 
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ public:
 | 
			
		||||
	virtual Word_t MemoryUsed() =0;
 | 
			
		||||
 | 
			
		||||
	virtual int Delete(cell Key) =0;
 | 
			
		||||
	virtual void Remove() =0;
 | 
			
		||||
 | 
			
		||||
	virtual void Set(cell Index, Pvoid_t value, bool disable_check = false) =0;
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@ public:
 | 
			
		||||
	virtual Word_t MemoryUsed() =0;
 | 
			
		||||
 | 
			
		||||
	virtual int Delete(char* Key) =0;
 | 
			
		||||
	virtual void Remove() =0;
 | 
			
		||||
 | 
			
		||||
	virtual void Set(char* Index, Pvoid_t value, bool disable_check = false) =0;
 | 
			
		||||
	
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
#define _BINTRIECLASS_H
 | 
			
		||||
 | 
			
		||||
#include "JudyIncludes.h"
 | 
			
		||||
#include "JudyExtra.h"
 | 
			
		||||
//#include <Judy1.h>
 | 
			
		||||
 | 
			
		||||
class BinTrie
 | 
			
		||||
@@ -13,9 +14,10 @@ private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	BinTrie()				{ Table = NULL; }
 | 
			
		||||
	~BinTrie()				{ Judy1FreeArray(&Table, PJE0); }
 | 
			
		||||
	~BinTrie()				{ Clear();		}
 | 
			
		||||
	void Remove()			{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()			{ return Judy1FreeArray(&Table, PJE0); }
 | 
			
		||||
	Word_t Clear()			{ JudyClearBinTrie(this); return Judy1FreeArray(&Table, PJE0); }
 | 
			
		||||
	Word_t MemoryUsed()		{ return Judy1MemUsed(Table); }
 | 
			
		||||
 | 
			
		||||
	cell Delete(cell Key)	{ return Judy1Unset(&Table, Key, PJE0 ); }
 | 
			
		||||
 
 | 
			
		||||
@@ -12,12 +12,13 @@ private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	Hashtable()					{ Table = NULL; }
 | 
			
		||||
	~Hashtable()				{ Clear(); }
 | 
			
		||||
	~Hashtable()				{ Clear();		}
 | 
			
		||||
	void Remove()				{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()				{ return JudyHSFreeArray(&Table, PJE0); }
 | 
			
		||||
	Word_t MemoryUsed()			{ return JudyLMemUsed(Table); }
 | 
			
		||||
 | 
			
		||||
	int Delete(char* Key)		{ delete Get(Key,true); return JudyHSDel(&Table, Key, strlen(Key), PJE0 ); }
 | 
			
		||||
	int Delete(char* Key)		{ return JudyHSDel(&Table, Key, strlen(Key), PJE0 ); }
 | 
			
		||||
 | 
			
		||||
	void Set(char* Index, Pvoid_t value, bool disable_check)
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -16,12 +16,13 @@ private:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	Keytable()				{ Table = NULL; }
 | 
			
		||||
	~Keytable()				{ Clear(); }
 | 
			
		||||
	~Keytable()				{ Clear(); 		}
 | 
			
		||||
	void Remove()			{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()			{ JudyClearMap(this); return JudySLFreeArray(&Table, PJE0); }
 | 
			
		||||
	Word_t MemoryUsed()		{ return JudyLMemUsed(Table); }
 | 
			
		||||
 | 
			
		||||
	int Delete(char* Key)	{ delete Get(Key,true); return JudySLDel(&Table, Key, PJE0 ); }
 | 
			
		||||
	int Delete(char* Key)	{ return JudySLDel(&Table, Key, PJE0 ); }
 | 
			
		||||
 | 
			
		||||
	void Set(char* Index, Pvoid_t value, bool disable_check)
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -27,13 +27,14 @@ protected:
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	Capsule()				{ data = NULL; type = capsule_type_none;}
 | 
			
		||||
	~Capsule()				{ Clear(); }
 | 
			
		||||
	~Capsule()				{ Clear(); 		}
 | 
			
		||||
	void Remove()			{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Capsule(bool set)		{ SetBool(set); }
 | 
			
		||||
	Capsule(cell set)		{ SetInt(set); }
 | 
			
		||||
	Capsule(REAL set)		{ SetFlo(set); }
 | 
			
		||||
	Capsule(JudyVec* set)	{ SetVec(set); }
 | 
			
		||||
	Capsule(char* set)		{ SetStr(set); }
 | 
			
		||||
	Capsule(cell set)		{ SetInt(set);	}
 | 
			
		||||
	Capsule(REAL set)		{ SetFlo(set);	}
 | 
			
		||||
	Capsule(JudyVec* set)	{ SetVec(set);	}
 | 
			
		||||
	Capsule(char* set)		{ SetStr(set);	}
 | 
			
		||||
 | 
			
		||||
	bool GetBool( void );
 | 
			
		||||
	void SetBool(bool set);
 | 
			
		||||
@@ -58,7 +59,7 @@ public:
 | 
			
		||||
	bool CheckEmpty(bool clear);
 | 
			
		||||
 | 
			
		||||
	Pvoid_t GetData( void )		{ return data; }
 | 
			
		||||
	char GetType( void )			{ return type; }
 | 
			
		||||
	char GetType( void )		{ return type; }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
@@ -12,13 +12,14 @@ private:
 | 
			
		||||
	Array MasterArray;
 | 
			
		||||
	
 | 
			
		||||
public:
 | 
			
		||||
	ComboArray()	{}
 | 
			
		||||
	~ComboArray() { Clear(); }
 | 
			
		||||
	ComboArray()			{				}
 | 
			
		||||
	~ComboArray()			{ Clear();		}
 | 
			
		||||
	void Remove()			{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()			{ return (MasterBin.Clear() + MasterArray.Clear() ); }
 | 
			
		||||
	Word_t MemoryUsed()		{ return (MasterBin.MemoryUsed() + MasterArray.MemoryUsed() ); }
 | 
			
		||||
 | 
			
		||||
	int Delete(cell Key)	{ return (MasterBin.Delete(Key) + MasterArray.Delete(Key) ); }
 | 
			
		||||
	int Delete(cell Key)	{  return (MasterBin.Delete(Key) + MasterArray.Delete(Key) ); }
 | 
			
		||||
 | 
			
		||||
	void Set(cell Index, Pvoid_t value, bool disable_check)
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -12,10 +12,11 @@ private:
 | 
			
		||||
	Hashtable MasterHash;
 | 
			
		||||
 | 
			
		||||
public:
 | 
			
		||||
	ComboTable()					{ }
 | 
			
		||||
	~ComboTable()				{ Clear(); }
 | 
			
		||||
	ComboTable()				{				}
 | 
			
		||||
	~ComboTable()				{ Clear();		}
 | 
			
		||||
	void Remove()				{ delete this;	}
 | 
			
		||||
 | 
			
		||||
	Word_t Clear()				{ return (MasterKey.Clear() + MasterHash.Clear() ); }
 | 
			
		||||
	Word_t Clear()				{ return (MasterHash.Clear() + MasterKey.Clear() ); }
 | 
			
		||||
	Word_t MemoryUsed()			{ return (MasterKey.MemoryUsed() + MasterHash.MemoryUsed() ); }
 | 
			
		||||
 | 
			
		||||
	int Delete(char* Key)		{ return (MasterKey.Delete(Key) + MasterHash.Delete(Key) ); }
 | 
			
		||||
@@ -25,8 +26,8 @@ public:
 | 
			
		||||
 | 
			
		||||
	void Set(char* Index, Pvoid_t value, bool disable_check)
 | 
			
		||||
	{
 | 
			
		||||
		MasterHash.Set(Index, value);
 | 
			
		||||
		MasterKey.Set(Index, value);
 | 
			
		||||
		MasterHash.Set(Index, value);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	Pvoid_t Get(char* Index, bool disable_check = false)
 | 
			
		||||
@@ -37,8 +38,8 @@ public:
 | 
			
		||||
	template <class Type> 
 | 
			
		||||
	void Set(char* Index, Type value)
 | 
			
		||||
	{
 | 
			
		||||
		MasterHash.Set(Index, value);
 | 
			
		||||
		MasterKey.Set(Index, value);
 | 
			
		||||
		MasterHash.Set(Index, value);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	template <class Type> 
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,11 @@ ComboArray MNAME;
 | 
			
		||||
		// generic_delete(id)
 | 
			
		||||
		static cell AMX_NATIVE_CALL JUDY_MASTER_DELETE_FUNC(AMX *amx,cell *params)
 | 
			
		||||
		{
 | 
			
		||||
			DTYPE* Unit = NULL;
 | 
			
		||||
			JUDY_GET_INDEX(MNAME,Unit, params[1] );
 | 
			
		||||
 | 
			
		||||
			Unit->Remove();
 | 
			
		||||
 | 
			
		||||
			try { return MNAME.Delete( params[1] ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (No error possible) - Delete function ");
 | 
			
		||||
		}
 | 
			
		||||
@@ -228,15 +233,25 @@ ComboArray MNAME;
 | 
			
		||||
		static cell AMX_NATIVE_CALL JUDY_SLAVE_REMOVE_FUNC(AMX *amx,cell *params)
 | 
			
		||||
		{
 | 
			
		||||
			DTYPE* Unit = NULL;
 | 
			
		||||
			STYPE* Storage;
 | 
			
		||||
 | 
			
		||||
			JUDY_GET_INDEX(MNAME,Unit, params[1]);
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage->Remove();
 | 
			
		||||
 | 
			
		||||
			try { return Unit->Delete(JUDY_GET_KEY(params,2) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (No error possible) - Slave Delete Function ");
 | 
			
		||||
			try { return Unit->Delete(Indice); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (No Error Possible) - Delete function ");
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
	#else
 | 
			
		||||
 | 
			
		||||
		#error Must Have Delete func: JUDY_SLAVE_DELETE_FUNC not defined!
 | 
			
		||||
		#ifdef NO_JUDY_SLAVE_REMOVE_FUNC
 | 
			
		||||
		#else
 | 
			
		||||
 | 
			
		||||
			#error Must Have Delete func: JUDY_SLAVE_REMOVE_FUNC not defined!
 | 
			
		||||
 | 
			
		||||
		#endif
 | 
			
		||||
 | 
			
		||||
	#endif
 | 
			
		||||
///*		End Required Slave Edit Funcs		*///
 | 
			
		||||
@@ -255,7 +270,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			bool Value = (params[3] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) Storage = new STYPE(Value);
 | 
			
		||||
			else Storage->SetBool(Value);
 | 
			
		||||
@@ -281,7 +296,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			bool disable_check = (params[3] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			try { Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) return 0;
 | 
			
		||||
@@ -313,7 +328,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			cell Value = params[3];
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) Storage = new STYPE(Value);
 | 
			
		||||
			else Storage->SetInt(Value);
 | 
			
		||||
@@ -339,7 +354,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			bool disable_check = (params[3] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			try { Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) return 0;
 | 
			
		||||
@@ -371,7 +386,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			REAL Value = amx_ctof(params[3]);
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) Storage = new STYPE(Value);
 | 
			
		||||
			else Storage->SetFlo(Value);
 | 
			
		||||
@@ -397,7 +412,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			bool disable_check = (params[3] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			try { Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) return 0;
 | 
			
		||||
@@ -429,7 +444,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			char* Value = MF_GetAmxString(amx,params[3],3,NULL);
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) Storage = new STYPE(Value);
 | 
			
		||||
			else Storage->SetStr(Value);
 | 
			
		||||
@@ -455,7 +470,7 @@ ComboArray MNAME;
 | 
			
		||||
			ITYPE Indice = JUDY_GET_KEY(params,2);
 | 
			
		||||
			bool disable_check = (params[5] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			try { Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) return 0;
 | 
			
		||||
@@ -493,7 +508,7 @@ ComboArray MNAME;
 | 
			
		||||
				amx_ctof(input_vec[2])
 | 
			
		||||
				);
 | 
			
		||||
		
 | 
			
		||||
			Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, true ) );
 | 
			
		||||
			Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, true ) );
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL) Storage = new STYPE(Value);
 | 
			
		||||
			else Storage->SetVec(Value);
 | 
			
		||||
@@ -520,7 +535,7 @@ ComboArray MNAME;
 | 
			
		||||
			cell *vAmx = MF_GetAmxAddr(amx, params[3]);
 | 
			
		||||
			bool disable_check = (params[4] != NULL);
 | 
			
		||||
		
 | 
			
		||||
			try { Storage = reinterpret_cast<Capsule*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			try { Storage = reinterpret_cast<STYPE*>( Unit->Get(Indice, disable_check ) ); }
 | 
			
		||||
			JUDY_ERROR_CATCH("Judy Error: (Retrieve unset value) - Slave Get Function ");
 | 
			
		||||
 | 
			
		||||
			if(Storage == NULL)
 | 
			
		||||
@@ -778,7 +793,10 @@ AMX_NATIVE_INFO EXPORT_NAME[] =
 | 
			
		||||
	{ JUDY_SLAVE_MEMORY_STR , JUDY_SLAVE_MEMORY_FUNC },
 | 
			
		||||
	{ JUDY_SLAVE_ISFILLED_STR , JUDY_SLAVE_ISFILLED_FUNC },
 | 
			
		||||
	{ JUDY_SLAVE_ISEMPTY_STR , JUDY_SLAVE_ISEMPTY_FUNC },
 | 
			
		||||
 | 
			
		||||
#ifndef NO_JUDY_SLAVE_REMOVE_FUNC
 | 
			
		||||
	{ JUDY_SLAVE_REMOVE_STR , JUDY_SLAVE_REMOVE_FUNC },
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef JUDY_SLAVE_EDIT_BOOL
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,34 @@
 | 
			
		||||
#include "JudyExtra.h"
 | 
			
		||||
#include "CBinTrie.h"
 | 
			
		||||
 | 
			
		||||
bool JudyClearMasterTrie(CBaseList* master)
 | 
			
		||||
{
 | 
			
		||||
	cell master_iten = NULL;
 | 
			
		||||
	BinTrie* Storage = NULL;
 | 
			
		||||
 | 
			
		||||
	try { master_iten = master->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
 | 
			
		||||
	while( true )
 | 
			
		||||
	{
 | 
			
		||||
		try { Storage = reinterpret_cast<BinTrie*>(master->Get(master_iten) );  }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
 | 
			
		||||
		Storage->Remove();
 | 
			
		||||
 | 
			
		||||
		try { master->Delete(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { return false; }
 | 
			
		||||
		
 | 
			
		||||
		try { master_iten = master->Next(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool JudyClearBinTrie(BinTrie* trie)
 | 
			
		||||
{
 | 
			
		||||
	Word_t trie_iten = 0;
 | 
			
		||||
	Word_t trie_iten = NULL;
 | 
			
		||||
 | 
			
		||||
	try { trie_iten = trie->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
@@ -19,7 +45,7 @@ bool JudyClearBinTrie(BinTrie* trie)
 | 
			
		||||
 | 
			
		||||
bool JudySaveBinTrie(BinTrie* trie, char* file)
 | 
			
		||||
{
 | 
			
		||||
	Word_t trie_iten = 0;
 | 
			
		||||
	Word_t trie_iten = NULL;
 | 
			
		||||
 | 
			
		||||
	try { trie_iten = trie->First(); }
 | 
			
		||||
	catch(JudyEx e) { return false; }
 | 
			
		||||
@@ -49,7 +75,7 @@ bool JudyLoadBinTrie(BinTrie* trie, char* file)
 | 
			
		||||
	FILE *trieDB = fopen(file, "ab+");
 | 
			
		||||
	if (!trieDB) return false;
 | 
			
		||||
 | 
			
		||||
	Word_t trie_iten = 0;
 | 
			
		||||
	Word_t trie_iten = NULL;
 | 
			
		||||
 | 
			
		||||
	bool value = false;
 | 
			
		||||
 | 
			
		||||
@@ -67,15 +93,46 @@ bool JudyLoadBinTrie(BinTrie* trie, char* file)
 | 
			
		||||
	return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool JudyClearMasterList(CBaseList* master)
 | 
			
		||||
{
 | 
			
		||||
	cell master_iten = NULL;
 | 
			
		||||
	CBaseList* Storage = NULL;
 | 
			
		||||
 | 
			
		||||
	try { master_iten = master->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
 | 
			
		||||
	while( true )
 | 
			
		||||
	{
 | 
			
		||||
		try { Storage = reinterpret_cast<CBaseList*>(master->Get(master_iten) );  }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
 | 
			
		||||
		Storage->Remove();
 | 
			
		||||
 | 
			
		||||
		try { master->Delete(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { return false; }
 | 
			
		||||
		
 | 
			
		||||
		try { master_iten = master->Next(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool JudyClearList(CBaseList* list)
 | 
			
		||||
{
 | 
			
		||||
	Word_t list_iten = 0;
 | 
			
		||||
	Word_t list_iten = NULL;
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
 | 
			
		||||
	try { list_iten = list->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
 | 
			
		||||
	while( true )
 | 
			
		||||
	{
 | 
			
		||||
		try { Storage = reinterpret_cast<Capsule*>(list->Get(list_iten) ); }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
 | 
			
		||||
		Storage->Remove();
 | 
			
		||||
 | 
			
		||||
		try { list->Delete(list_iten); }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
		
 | 
			
		||||
@@ -88,7 +145,7 @@ bool JudyClearList(CBaseList* list)
 | 
			
		||||
bool JudySaveList(CBaseList* list, char* file)
 | 
			
		||||
{
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
	Word_t list_iten = 0;
 | 
			
		||||
	Word_t list_iten = NULL;
 | 
			
		||||
	bool no_error = true;
 | 
			
		||||
 | 
			
		||||
	try { list_iten = list->First(); }
 | 
			
		||||
@@ -120,7 +177,7 @@ bool JudyLoadList(CBaseList* list, char* file)
 | 
			
		||||
	if (!listDB) return false;
 | 
			
		||||
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
	Word_t list_iten = 0;
 | 
			
		||||
	Word_t list_iten = NULL;
 | 
			
		||||
	bool no_error = true;
 | 
			
		||||
 | 
			
		||||
	while(!feof(listDB))
 | 
			
		||||
@@ -139,15 +196,46 @@ bool JudyLoadList(CBaseList* list, char* file)
 | 
			
		||||
	return no_error;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool JudyClearMasterMap(CBaseList* master)
 | 
			
		||||
{
 | 
			
		||||
	cell master_iten = NULL;
 | 
			
		||||
	CBaseMap* Storage = NULL;
 | 
			
		||||
 | 
			
		||||
	try { master_iten = master->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
 | 
			
		||||
	while( true )
 | 
			
		||||
	{
 | 
			
		||||
		try { Storage = reinterpret_cast<CBaseMap*>(master->Get(master_iten) );  }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
 | 
			
		||||
		Storage->Remove();
 | 
			
		||||
 | 
			
		||||
		try { master->Delete(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { return false; }
 | 
			
		||||
		
 | 
			
		||||
		try { master_iten = master->Next(master_iten); }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return true;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
bool JudyClearMap(CBaseMap* map)
 | 
			
		||||
{
 | 
			
		||||
	char* map_iten = NULL;
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
 | 
			
		||||
	try { map_iten = map->First(); }
 | 
			
		||||
	catch(JudyEx& e) { return false; }
 | 
			
		||||
 | 
			
		||||
	while( true )
 | 
			
		||||
	{
 | 
			
		||||
		try { Storage = reinterpret_cast<Capsule*>(map->Get(map_iten) );  }
 | 
			
		||||
		catch(JudyEx& e) { break; }
 | 
			
		||||
 | 
			
		||||
		Storage->Remove();
 | 
			
		||||
 | 
			
		||||
		try { map->Delete(map_iten); }
 | 
			
		||||
		catch(JudyEx& e) { return false; }
 | 
			
		||||
		
 | 
			
		||||
@@ -163,7 +251,7 @@ bool JudySaveMap(CBaseMap* map, char* file)
 | 
			
		||||
{
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
	char* map_iten = NULL;
 | 
			
		||||
	size_t key_len = 0;
 | 
			
		||||
	size_t key_len = NULL;
 | 
			
		||||
	bool no_error = true;
 | 
			
		||||
 | 
			
		||||
	try { map_iten = map->First(); }
 | 
			
		||||
@@ -200,7 +288,7 @@ bool JudyLoadMap(CBaseMap* map, char* file)
 | 
			
		||||
 | 
			
		||||
	Capsule* Storage = NULL;
 | 
			
		||||
	char* map_iten = NULL;
 | 
			
		||||
	size_t key_len = 0;
 | 
			
		||||
	size_t key_len = NULL;
 | 
			
		||||
	bool no_error = true;
 | 
			
		||||
 | 
			
		||||
	while(!feof(mapDB))
 | 
			
		||||
 
 | 
			
		||||
@@ -1,18 +1,22 @@
 | 
			
		||||
#ifndef _JUDYARRAY_SHARED_INCLUDED
 | 
			
		||||
#define _JUDYARRAY_SHARED_INCLUDED
 | 
			
		||||
 | 
			
		||||
#include "CBinTrie.h"
 | 
			
		||||
#include "CBaseList.h"
 | 
			
		||||
#include "CBaseMap.h"
 | 
			
		||||
 | 
			
		||||
class BinTrie;
 | 
			
		||||
 | 
			
		||||
extern bool JudyClearMasterTrie(CBaseList* master);
 | 
			
		||||
extern bool JudyClearBinTrie(BinTrie* trie);
 | 
			
		||||
extern bool JudySaveBinTrie(BinTrie* trie, char* file);
 | 
			
		||||
extern bool JudyLoadBinTrie(BinTrie* trie, char* file);
 | 
			
		||||
 | 
			
		||||
extern bool JudyClearMasterList(CBaseList* master);
 | 
			
		||||
extern bool JudyClearList(CBaseList* list);
 | 
			
		||||
extern bool JudySaveList(CBaseList* list, char* file);
 | 
			
		||||
extern bool JudyLoadList(CBaseList* list, char* file);
 | 
			
		||||
 | 
			
		||||
extern bool JudyClearMasterMap(CBaseList* master);
 | 
			
		||||
extern bool JudyClearMap(CBaseMap* map);
 | 
			
		||||
extern bool JudySaveMap(CBaseMap* array, char* file);
 | 
			
		||||
extern bool JudyLoadMap(CBaseMap* array, char* file);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user