extensions/regex/extension.cpp
branchsourcemod-1.1.0
changeset 1919 fe6181f4b9d2
parent 1842 9a93a6e6ac01
     1.1 --- a/extensions/regex/extension.cpp	Thu Jan 17 00:31:58 2008 +0000
     1.2 +++ b/extensions/regex/extension.cpp	Tue Mar 04 23:18:16 2008 +0000
     1.3 @@ -32,7 +32,6 @@
     1.4  #include "extension.h"
     1.5  
     1.6  #include <sh_string.h>
     1.7 -#include <sh_vector.h>
     1.8  #include "pcre.h"
     1.9  #include "CRegEx.h"
    1.10  using namespace SourceHook;
    1.11 @@ -50,21 +49,6 @@
    1.12  HandleType_t g_RegexHandle=0;
    1.13  
    1.14  
    1.15 -SourceHook::CVector<RegEx *> PEL;
    1.16 -
    1.17 -int GetPEL()
    1.18 -{
    1.19 -	for (int i=0; i<(int)PEL.size(); i++)
    1.20 -	{
    1.21 -		if (PEL[i]->isFree())
    1.22 -			return i;
    1.23 -	}
    1.24 -
    1.25 -	RegEx *x = new RegEx();
    1.26 -	PEL.push_back(x);
    1.27 -
    1.28 -	return (int)PEL.size() - 1;
    1.29 -}
    1.30  
    1.31  bool RegexExtension::SDK_OnLoad(char *error, size_t err_max, bool late)
    1.32  {
    1.33 @@ -76,15 +60,7 @@
    1.34  void RegexExtension::SDK_OnUnload()
    1.35  {
    1.36  	g_pHandleSys->RemoveType(g_RegexHandle, myself->GetIdentity());
    1.37 -	for(int i=0; i<(int)PEL.size(); i++)
    1.38 -	{
    1.39 -		if(PEL[i])
    1.40 -		{
    1.41 -			delete PEL[i];
    1.42 -			PEL[i] = 0;
    1.43 -		}
    1.44 -	}
    1.45 -	PEL.clear();
    1.46 +
    1.47  }
    1.48  
    1.49  static cell_t CompileRegex(IPluginContext *pCtx, const cell_t *params)
    1.50 @@ -92,8 +68,7 @@
    1.51  	char *regex;
    1.52  	pCtx->LocalToString(params[1], &regex);
    1.53  
    1.54 -	int id = GetPEL();
    1.55 -	RegEx *x = PEL[id];
    1.56 +	RegEx *x = new RegEx();
    1.57  	
    1.58  	if (x->Compile(regex, params[2]) == 0)
    1.59  	{
    1.60 @@ -201,6 +176,7 @@
    1.61  	RegEx *x = (RegEx *)object;
    1.62  
    1.63  	x->Clear();
    1.64 +	delete x;
    1.65  }
    1.66  
    1.67  const sp_nativeinfo_t regex_natives[] =