* This also means that there is no need to check if the call succeeded.
*
* It's important to match g_malloc() (and wrappers such as g_new()) with
- * g_free(), g_slice_alloc() and wrappers such as g_slice_new()) with
+ * g_free(), g_slice_alloc() (and wrappers such as g_slice_new()) with
* g_slice_free(), plain malloc() with free(), and (if you're using C++)
* new with delete and new[] with delete[]. Otherwise bad things can happen,
* since these allocators may use different memory pools (and new/delete call
* Otherwise, the variable is destroyed using @destroy and the
* pointer is set to %NULL.
*
- * This function is threadsafe and modifies the pointer atomically,
- * using memory barriers where needed.
- *
* A macro is also included that allows this function to be used without
* pointer casts.
*
{
gpointer _p;
- /* This is a little frustrating.
- * Would be nice to have an atomic exchange (with no compare).
- */
- do
- _p = g_atomic_pointer_get (pp);
- while G_UNLIKELY (!g_atomic_pointer_compare_and_exchange (pp, _p, NULL));
-
+ _p = *pp;
if (_p)
- destroy (_p);
+ {
+ *pp = NULL;
+ destroy (_p);
+ }
}
/**
*
* A different allocator can be set using g_mem_set_vtable().
*
- * Return value: if %TRUE, malloc() and g_malloc() can be mixed.
+ * Returns: if %TRUE, malloc() and g_malloc() can be mixed.
**/
gboolean
g_mem_is_system_malloc (void)