/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (!mFunction) { // Since the function doesn't exist, there is no point in holding a // reference to mModule anymore.
::FreeLibrary(mModule);
mModule = nullptr;
}
}
/** * In most cases, this class is the one that you want to use for resolving a * dynamically-linked function pointer. It should be instantiated as a static * local variable. * * NB: It has a trivial destructor, so the DLL that is loaded is never freed. * Assuming that this function is called fairly often, this is the most * sensible option. OTOH, if the function you are calling is a one-off, or the * static local requirement is too restrictive, use DynamicallyLinkedFunctionPtr * instead.
*/ template <typename T> class MOZ_STATIC_LOCAL_CLASS StaticDynamicallyLinkedFunctionPtr final
: public detail::DynamicallyLinkedFunctionPtrBase<T> { public:
StaticDynamicallyLinkedFunctionPtr(constwchar_t* aLibName, constchar* aFuncName)
: detail::DynamicallyLinkedFunctionPtrBase<T>(aLibName, aFuncName) {}
/** * We only offer this operator for the static local case, as it is not * possible for this object to be destroyed while the returned pointer is * being held.
*/ operatortypename detail::DynamicallyLinkedFunctionPtrBase<T>::FunctionPtrT() const { return this->mFunction;
}
};
template <typename T> class MOZ_NON_PARAM MOZ_NON_TEMPORARY_CLASS DynamicallyLinkedFunctionPtr final
: public detail::DynamicallyLinkedFunctionPtrBase<T> { public:
DynamicallyLinkedFunctionPtr(constwchar_t* aLibName, constchar* aFuncName)
: detail::DynamicallyLinkedFunctionPtrBase<T>(aLibName, aFuncName) {}
~DynamicallyLinkedFunctionPtr() { if (!this->mModule) { return;
}
::FreeLibrary(this->mModule);
}
};
} // namespace mozilla
#endif// mozilla_DynamicallyLinkedFunctionPtr_h
¤ Dauer der Verarbeitung: 0.25 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.