Search completed in 1.08 seconds.
12 results for "NS_Alloc":
NS_Alloc
MozillaTechXPCOMReferenceCore functionsNS Alloc
#include "nsxpcom.h" void* ns_alloc( prsize asize ); parameters asize [in] the size in bytes of the block to allocate.
Choosing the right memory allocator
MozillaChoosing 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.
...for data structures being passed across xpcom boundaries, use ns_alloc() instead.
Infallible memory allocation
MozillaInfallible memory allocation
ns_alloc() is also infallible.
... p = malloc(); p = realloc(); namespace mozilla { f = new (fallible) foo(); farray = new (fallible) foo[]; } namespace mozilla { n = ::operator new(..., fallible); narray = ::operator new[](..., fallible); } see also choosing the right memory allocator ns_alloc() ...
NS_GetMemoryManager
MozillaTechXPCOMReferenceCore functionsNS GetMemoryManager
any code, intended to be used exclusively with mozilla 1.8 and above, may use ns_alloc, ns_realloc, and ns_free instead to access the xpcom memory manager's methods.
... see also nsimemory, ns_alloc ...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
ArchiveAdd-onsMigrating from Internal Linkage to Frozen Linkage
scrt.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.
Index
MozillaTechXPCOMIndex
127 ns_alloc functions, functions:frozen, needsrelocation, reference, référence(2), xpcom, xpcom api reference infallibly allocates a block of memory using the xpcom memory manager.
NS_Free
MozillaTechXPCOMReferenceCore functionsNS Free
see also ns_alloc, nsimemory, ns_getmemorymanager ...
NS_Realloc
MozillaTechXPCOMReferenceCore functionsNS Realloc
this pointer must have been previously allocated by the xpcom memory manager, or this parameter may be null in which case this function behaves like ns_alloc.
Core XPCOM functions
MozillaTechXPCOMReferenceCore functions
ns_allocinfallibly allocates a block of memory using the xpcom memory manager.ns_freefrees a block of memory using the xpcom memory manager.ns_getcomponentmanagerthe ns_getcomponentmanager function returns a reference to the xpcom component manager.ns_getcomponentregistrarthe ns_getcomponentregistrar function returns a reference to the xpcom component registrar.ns_getmemorymanagerthe ns_getmemorymanager function returns a reference to the xpcom memory manager.ns_getservicemanagerthe ns_getservicemanager function returns a reference to the xpcom service manager.ns_initxpcom2the ns_initxpcom2 funct...
nsXPIDLCString
MozillaTechXPCOMReferenceGlue classesnsXPIDLCString
class declaration nstxpidlstring extends nststring such that: (1) mdata can be null (2) objects of this type can be automatically cast to |const chart*| (3) getter_copies method is supported to adopt data allocated with ns_alloc, such as "out string" parameters in xpidl.
nsXPIDLString
MozillaTechXPCOMReferenceGlue classesnsXPIDLString
class declaration nstxpidlstring extends nststring such that: (1) mdata can be null (2) objects of this type can be automatically cast to |const chart*| (3) getter_copies method is supported to adopt data allocated with ns_alloc, such as "out string" parameters in xpidl.
XPIDL
MozillaTechXPIDL
for buffers, the callee allocates the buffer with ns_alloc, and the caller frees the buffer with ns_free.