Search completed in 1.36 seconds.
10 results for "ns_free":
NS_Free
Mozilla › Tech › XPCOM › Reference › Core functions › NS Free
Remarks This function provides a convenient way to access the XPCOM memory manager. It is equivalent to calling free on the nsIMemory instance returned from NS_GetMemoryManager. ...
Mozilla internal string guide
Mozilla › Tech › XPCOM › Guide › Internal strings
below. char* ToNewUTF8String(nsAString&) - Allocates a new char* buffer containing the UTF-8 encoded version of the given nsAString. See Unicode Conversion for more details and for better ways that don't require you to manage the memory yourself. These methods return a buffer allocated using XPCOM's allocator instead of the traditional allocator (malloc, etc.). Outside of libxul you should use NS_Free to deallocate the result when you no longer need it, inside libxul free() is preferred.. Substrings (string fragments) It is very simple to refer to a substring of an existing string without actually allocating new space and copying the characters into that substring. Substring() is the preferred method to create a reference to such a string. void ProcessString(const nsAString& str) { cons...
...e the string when they have finished using it. Fortunately, the getter_Copies() function makes this very easy. A method may look like this: void GetValue(char16_t** aValue) { *aValue = ToNewUnicode(foo); } Without getter_Copies(), the caller would need to free the string: { char16_t* val; GetValue(&val); if (someCondition) { // don't forget to free the value! NS_Free(val); return NS_ERROR_FAILURE; } ... // and later, still don't forget to free! NS_Free(val); } With getter_copies() you never have to worry about this. You can just use getter_Copies() to wrap a string class argument, and the class will remember to free the buffer when it goes out of scope: { nsString val; GetValue(getter_Copies(val)); // val will free its...
Migrating from Internal Linkage to Frozen Linkage - Archive of obsolete content
Archive › Add-ons › Migrating from Internal Linkage to Frozen Linkage
The nsMsgUtils.h header For developing core Mail/News code, the nsMsgUtils.h header is being enhanced to fill in some of the gaps caused by the differences between the internal and external APIs. These enhancements make it easier to write code that will transparently compile using eith...
Choosing the right memory allocator
Mozilla › Choosing the right memory allocator
ces. Allocating memory in XPCOM These are general purpose memory-management routines that you should use unless your code falls into one of the other categories below. Use these if you link against XPCOM or XPCOM Glue; this includes extensions with binary components. See the XPCOM string guide for additional information. 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. Allocating strings in XPCOM code See "Callee-allocated Parameters" in the XPCOM Strings guide; use ToNewCString() or ToNewUnicod...
Index
Mozilla › Tech › XPCOM › Index
ides a number of global functions which are used to initialize and shut down the XPCOM library, as well as to allocate memory, get access to services, and to instantiate interfaces. 127 NS_Alloc Functions, Functions:Frozen, NeedsRelocation, Reference, Reference(2), XPCOM, XPCOM API Reference Infallibly allocates a block of memory using the XPCOM memory manager. 128 NS_Free Functions, Functions:Frozen, XPCOM, XPCOM API Reference Frees a block of memory using the XPCOM memory manager. 129 NS_GetComponentManager Functions, Functions:Frozen, XPCOM, XPCOM API Reference The NS_GetComponentManager function returns a reference to the XPCOM Component Manager. 130 NS_GetComponentRegistrar Functions, Functions:Frozen, XPCOM, XPCOM...
NS_Alloc
Mozilla › Tech › XPCOM › Reference › Core functions › NS Alloc
pointer to the allocated block of memory, which is suitably aligned for any kind of variable, or null if the allocation failed. Remarks This function provides a convenient way to access the XPCOM memory manager. It is equivalent to calling alloc on the nsIMemory instance returned from NS_GetMemoryManager. History This function was finalized for Mozilla 1.8. See bug 267767 for details. See also NS_Free, nsIMemory, NS_GetMemoryManager ...
NS_GetMemoryManager
Mozilla › Tech › XPCOM › Reference › Core functions › NS GetMemoryManager
emory Manager. Return Values The NS_GetMemoryManager function returns NS_OK if successful. Otherwise, it returns an error code. Remarks The object returned is a singleton that is valid until NS_ShutdownXPCOM is called. The interface pointer should be Release'd when it is no longer needed. 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. History This function was finalized for Mozilla 0.9.7. See bug 112262 for details. See Also nsIMemory, NS_Alloc ...
Core XPCOM functions
Mozilla › Tech › XPCOM › Reference › Core functions
XPCOM provides a number of global functions which are used to initialize and shut down the XPCOM library, as well as to allocate memory, get access to services, and to instantiate interfaces. ...
nsIProperties
Mozilla › Tech › XPCOM › Reference › Interface › nsIProperties
sIIDRef iid, [iid_is(iid),retval] out nsQIResult result ); Parameters prop The property name. iid The desired interface. result The resulting object instance. Exceptions thrown NS_ERROR_FAILURE If the property does not exist. NS_ERROR_NO_INTERFACE If the property exists, but does not support the requested interface. getKeys() Returns an array of property names. nsMemory.h defines the macro NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY, which can be used to free aKeys when it is no longer needed. void getKeys( out PRUint32 count, [array, size_is(count), retval] out string keys ); Parameters count The length of the result array. keys The resulting array of keys. has() Tests if a property exists. boolean has( in string prop ); Parameters prop The property name. Return value true if the pr...
XPIDL
Mozilla › Tech › XPIDL
n parameters, the caller allocates and deallocates all data. If the callee needs to use the data after the call completes, it must make a private copy of the data, or, in the case of interface pointers, AddRef it. For out parameters, the callee creates the data, and transfers ownership to the caller. For buffers, the callee allocates the buffer with NS_Alloc, and the caller frees the buffer with NS_Free. For interface pointers, the callee does the AddRef on behalf of the caller, and the caller must call Release. For inout parameters, the callee must clean up the old data if it chooses to replace it. Buffers must be deallocated with NS_Free, and interface pointers must be Release'd. Afterwards, the above rules for out apply. Shared out-parameters should not be freed, as they are intended to ref...