diff -r 962d2947c6d6 -r 2b1bf332bf41 metamod/mplugin.cpp --- a/metamod/mplugin.cpp Thu Nov 11 23:21:08 2004 +0000 +++ b/metamod/mplugin.cpp Fri Feb 18 20:52:34 2005 +0000 @@ -726,7 +726,7 @@ // Make copy of gameDLL's function tables for each plugin, so we don't // risk the plugins screwing with the tables everyone uses. if(GameDLL.funcs.dllapi_table && !gamedll_funcs.dllapi_table) { - gamedll_funcs.dllapi_table = (DLL_FUNCTIONS *) malloc(sizeof(DLL_FUNCTIONS)); + gamedll_funcs.dllapi_table = (DLL_FUNCTIONS *) calloc(1, sizeof(DLL_FUNCTIONS)); if(!gamedll_funcs.dllapi_table) { META_ERROR("dll: Failed attach plugin '%s': Failed malloc() for dllapi_table"); RETURN_ERRNO(mFALSE, ME_NOMEM); @@ -764,7 +764,8 @@ // a function isn't an option since we have varying types. #define GET_FUNC_TABLE_FROM_PLUGIN(pfnGetFuncs, STR_GetFuncs, struct_field, API_TYPE, TABLE_TYPE, vers_pass, vers_int, vers_want) \ if(meta_table.pfnGetFuncs) { \ - struct_field = (TABLE_TYPE*) calloc(1, sizeof(TABLE_TYPE)); \ + if (!struct_field) \ + struct_field = (TABLE_TYPE*) calloc(1, sizeof(TABLE_TYPE)); \ if(meta_table.pfnGetFuncs(struct_field, vers_pass)) { \ META_DEBUG(3, ("dll: Plugin '%s': Found %s", desc, STR_GetFuncs)); \ } \ @@ -776,6 +777,8 @@ } \ else { \ META_DEBUG(5, ("dll: Plugin '%s': No %s", desc, STR_GetFuncs)); \ + if (struct_field) \ + free(struct_field); \ struct_field=NULL; \ } @@ -934,6 +937,7 @@ else if(action==PA_RELOAD) { status=PL_VALID; action=PA_LOAD; + clear(); } META_LOG("dll: Unloaded plugin '%s' for reason '%s'", desc, str_reason(reason)); return(mTRUE);