diff --git a/core/logic/NativeOwner.cpp b/core/logic/NativeOwner.cpp index c559d188..969e07a9 100644 --- a/core/logic/NativeOwner.cpp +++ b/core/logic/NativeOwner.cpp @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourcePawn * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. @@ -58,17 +58,10 @@ void CNativeOwner::AddWeakRef(const WeakNative & ref) void CNativeOwner::AddNatives(const sp_nativeinfo_t *natives) { - NativeEntry *pEntry; + for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++) + g_ShareSys.AddNativeToCache(this, native); - for (unsigned int i = 0; natives[i].func != NULL && natives[i].name != NULL; i++) - { - if ((pEntry = g_ShareSys.AddNativeToCache(this, &natives[i])) == NULL) - { - continue; - } - - m_Natives.push_back(pEntry); - } + m_natives.append(natives); } void CNativeOwner::PropagateMarkSerial(unsigned int serial) @@ -113,7 +106,6 @@ void CNativeOwner::DropEverything() { NativeEntry *pEntry; List::iterator iter; - List::iterator ntv_iter; /* Unbind and remove all weak references to us */ iter = m_WeakRefs.begin(); @@ -124,7 +116,13 @@ void CNativeOwner::DropEverything() } /* Strip all of our natives from the cache */ - ntv_iter = m_Natives.begin(); + for (size_t i = 0; i < m_natives.length(); i++) { + const sp_nativeinfo_t *natives = m_natives[i]; + for (const sp_nativeinfo_t *native = natives; native->func && native->name; native++) + g_ShareSys.ClearNativeFromCache(this, native->name); + } + + List::iterator ntv_iter = m_Natives.begin(); while (ntv_iter != m_Natives.end()) { g_ShareSys.ClearNativeFromCache(this, (*ntv_iter)->name); diff --git a/core/logic/NativeOwner.h b/core/logic/NativeOwner.h index a61c63f0..e3f9f872 100644 --- a/core/logic/NativeOwner.h +++ b/core/logic/NativeOwner.h @@ -1,8 +1,39 @@ +/** + * vim: set ts=4 sw=4 tw=99 noet : + * ============================================================================= + * SourcePawn + * Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ #ifndef _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ #define _INCLUDE_SOURCEMOD_NATIVE_OWNER_H_ #include #include +#include #include "common_logic.h" struct NativeEntry; @@ -54,6 +85,7 @@ protected: List m_Dependents; unsigned int m_nMarkSerial; List m_WeakRefs; + ke::Vector m_natives; List m_Natives; };