metamod/mplugin.cpp
changeset 247 2b1bf332bf41
parent 246 962d2947c6d6
child 248 f72386298cba
     1.1 --- a/metamod/mplugin.cpp	Thu Nov 11 23:21:08 2004 +0000
     1.2 +++ b/metamod/mplugin.cpp	Fri Feb 18 20:52:34 2005 +0000
     1.3 @@ -726,7 +726,7 @@
     1.4  	// Make copy of gameDLL's function tables for each plugin, so we don't
     1.5  	// risk the plugins screwing with the tables everyone uses.
     1.6  	if(GameDLL.funcs.dllapi_table && !gamedll_funcs.dllapi_table) {
     1.7 -		gamedll_funcs.dllapi_table = (DLL_FUNCTIONS *) malloc(sizeof(DLL_FUNCTIONS));
     1.8 +		gamedll_funcs.dllapi_table = (DLL_FUNCTIONS *) calloc(1, sizeof(DLL_FUNCTIONS));
     1.9  		if(!gamedll_funcs.dllapi_table) {
    1.10  			META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for dllapi_table");
    1.11  			RETURN_ERRNO(mFALSE, ME_NOMEM);
    1.12 @@ -764,7 +764,8 @@
    1.13  	// a function isn't an option since we have varying types.
    1.14  #define GET_FUNC_TABLE_FROM_PLUGIN(pfnGetFuncs, STR_GetFuncs, struct_field, API_TYPE, TABLE_TYPE, vers_pass, vers_int, vers_want) \
    1.15  	if(meta_table.pfnGetFuncs) { \
    1.16 -		struct_field = (TABLE_TYPE*) calloc(1, sizeof(TABLE_TYPE)); \
    1.17 +		if (!struct_field) \
    1.18 +			struct_field = (TABLE_TYPE*) calloc(1, sizeof(TABLE_TYPE)); \
    1.19  		if(meta_table.pfnGetFuncs(struct_field, vers_pass)) { \
    1.20  			META_DEBUG(3, ("dll: Plugin '%s': Found %s", desc, STR_GetFuncs)); \
    1.21  		} \
    1.22 @@ -776,6 +777,8 @@
    1.23  	} \
    1.24  	else { \
    1.25  		META_DEBUG(5, ("dll: Plugin '%s': No %s", desc, STR_GetFuncs)); \
    1.26 +		if (struct_field) \
    1.27 +			free(struct_field); \
    1.28  		struct_field=NULL; \
    1.29  	}
    1.30  
    1.31 @@ -934,6 +937,7 @@
    1.32  	else if(action==PA_RELOAD) {
    1.33  		status=PL_VALID;
    1.34  		action=PA_LOAD;
    1.35 +		clear();
    1.36  	}
    1.37  	META_LOG("dll: Unloaded plugin '%s' for reason '%s'", desc, str_reason(reason));
    1.38  	return(mTRUE);