Search completed in 1.07 seconds.
17 results for "nsMemory":
Your results are loading. Please wait...
nsMemory
« xpcom api reference summary the nsmemory class provides static helper routines to manage memory.
...#include "nsmemory.h" class nsmemory { ...
Starting WebLock
component as an xpcom-startup observer, do the following: char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, // persist category pr_true, // replace existing &previous); if (previous) nsmemory::free(previous); // free the memory the replaced value might have used the unregistration, which should occur in the unregistration callback, looks like this: rv = catman->deletecategoryentry("xpcom-startup", "weblock", pr_true); // persist a complete code listing for registering weblock as a startup observer follows: #defi...
...ne mozilla_strict_api #include "nsigenericfactory.h" #include "nscomptr.h" #include "nsxpcom.h" #include "nsiservicemanager.h" #include "nsicategorymanager.h" #include "nsmemory.h" #include "nsiobserver.h" #include "nsembedstring.h" #define weblock_cid \ { 0x777f7150, 0x4a2b, 0x4301, \ { 0xad, 0x10, 0x5e, 0xab, 0x25, 0xb3, 0x22, 0xaa}} #define weblock_contractid "@dougt/weblock" class weblock: public nsiobserver { public: weblock(); virtual ~weblock(); ns_decl_isupports ns_decl_nsiobserver }; weblock::weblock() { ns_init_isupports(); } weblock::~weblock() { } ns_impl_isupports1(weblock, nsiobserver); ns_imethodimp weblock::observe(nsisupports *asubject, const char *atopic, const prunichar *adata) { return ns_ok; } static ns_method weblockregistration(nsicomponen...
... getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); return rv; } static ns_method weblockunregistration(nsicomponentmanager *acompmgr, nsifile *apath, const char *registrylocation, const nsmodulecomponentinfo *info) { nsresult rv; nscomptr<nsiservicemanager> servman = do_queryinterface((nsisupports*)acompmg...
...And 4 more matches
Overview of Mozilla embedding APIs
nsmemory nsmemory::alloc nsmemory::realloc nsmemory::free this helper class provides static accessors to the global nsmemory service.
...implemented interfaces: nsiservicemanager related interfaces: nsishutdownlistener nsmemory the nsmemory service provides the global memory manager implementation for xpcom.
...all heap access should be done via the nsmemory service.
... to facilitate this, a set of global functions are available to access the nsmemory methods without requiring an instance of the nsmemory service (see nsmemory.h).
Realloc
this may be nsnull, in which case realloc behaves like nsmemory::alloc.
...this may be 0, in which case realloc behaves like nsmemory::free.
...the result must be freed with a call to nsmemory::free when it is no longer needed.
... see also nsmemory::free ...
DMD
lecollector::sizeofincludingthis(unsigned long (*)(void const*), unsigned long*, unsigned long*, unsigned long*, unsigned long*, unsigned long*) const (/home/njn/moz/mi2/xpcom/base/nscyclecollector.cpp:3029) 0x7f6860fdb6b1 #05: cyclecollectormultireporter::collectreports(nsimemorymultireportercallback*, nsisupports*) (/home/njn/moz/mi2/xpcom/base/nscyclecollector.cpp:3075) 0x7f6860fde432 #06: nsmemoryinfodumper::dumpmemoryreportstofileimpl(nsastring_internal const&) (/home/njn/moz/mi2/xpcom/base/nsmemoryinfodumper.cpp:626) 0x7f6860fece79 #07: nsmemoryinfodumper::dumpmemoryreportstofile(nsastring_internal const&, bool, bool) (/home/njn/moz/mi2/xpcom/base/nsmemoryinfodumper.cpp:344) 0x7f6860febaf9 #08: mozilla::(anonymous namespace)::dumpmemoryreportsrunnable::run() (/home/njn/moz/mi2/xpcom/...
...base/nsmemoryinfodumper.cpp:58) 0x7f6860fefe03 } you can tell which memory reporter made the report by the name of the mallocsizeof function near the top of the stack trace.
Alloc
the result must be freed with a call to nsmemory::free() when it is no longer needed.
... see also nsmemory::free() ...
Clone
the result must be freed with a call to nsmemory::free when it is no longer needed.
... see also nsmemory::free ...
NS_CStringCloneData
the resulting buffer may be freed by calling nsmemory::free.
... see also nsmemory::free, nsacstring ...
NS_StringCloneData
the resulting buffer may be freed by calling nsmemory::free.
... see also nsmemory::free, nsastring ...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
- #include "nscrt.h" + #include <string.h> const char *str = "foo"; - pruint32 len = nscrt::strlen(str); + pruint32 len = strlen(str); - #include "nscrt.h" + #include "nscrtglue.h" const prunichar str[] = {'f','o','o','\0'}; - pruint32 len = nscrt::strlen(str); + pruint32 len = ns_strlen(str); - #include "nscrt.h" + #include "nsmemory.h" + #include "nscrtglue.h" prunichar* anotherstr = (prunichar*) ns_alloc(100 * sizeof(prunichar)); - prunichar *str = nscrt::strdup(anotherstr); - nscrt::free(str); + prunichar *str = ns_strdup(anotherstr); + ns_free(str); linking for information about the correct libraries to link to when using frozen linkage, see xpcom glue.
Choosing the right memory allocator
ns_alloc() == nsimemory::alloc() ns_realloc() == nsimemory::realloc() ns_free() == nsimemory::free() nsmemory::clone() (note: not part of nsimemory) see infallible memory allocation for information about how to allocate memory infallibly; that is, how to use memory allocators that will only return valid memory buffers, and never return null.
Component Internals
the smart pointer class, nscomptr, for example, which makes reference counting less tedious and error-prone, is not actually frozen, and neither is nsdebug, a class for aiding in tracking down bugs, nor is nsmemory, a class to ensure that everyone uses the same heap, generic factory, and module.
Finishing the Component
getter_addrefs(catman)); if (ns_failed(rv)) return rv; char* previous = nsnull; rv = catman->addcategoryentry("xpcom-startup", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); rv = catman->addcategoryentry("content-policy", "weblock", weblock_contractid, pr_true, pr_true, &previous); if (previous) nsmemory::free(previous); return rv; } this code adds a new category entry under the t...
Index
MozillaTechXPCOMIndex
1209 nsfixedcstring class declaration 1210 nsfixedstring class declaration 1211 nsliteralcstring (external) needscontent, reference, référence(2), strings class declaration 1212 nsliteralstring (external) needscontent, reference, référence(2), strings class declaration 1213 nsmemory needsrelocation, reference, référence(2), xpcom, xpcom api reference the nsmemory class provides static helper routines to manage memory.
XPCOM glue classes
he nsembedcstring concrete class provides a way to construct a nsacstring object that allocates null-terminated storage.nsembedstringthe nsembedstring concrete class provides a way to construct a nsastring object that allocates null-terminated storage.nsfixedcstringclass declarationnsfixedstringclass declarationnsliteralcstring (external)class declarationnsliteralstring (external)class declarationnsmemorythe nsmemory class provides static helper routines to manage memory.
nsIMsgDatabase
the caller should free when done using nsmemory.free().
nsIProperties
nsmemory.h defines the macro ns_free_xpcom_allocated_pointer_array, which can be used to free akeys when it is no longer needed.