Beispiel #1
0
gpointer
g_try_realloc (gpointer mem,
	       gulong   n_bytes)
{
  if (n_bytes)
    return glib_mem_vtable.try_realloc (mem, n_bytes);

  if (mem)
    glib_mem_vtable.free (mem);

  return NULL;
}
Beispiel #2
0
gpointer
g_try_realloc (gpointer mem,
               gsize    n_bytes)
{
    if (G_UNLIKELY (!g_mem_initialized))
        g_mem_init_nomessage();
    if (G_LIKELY (n_bytes))
        return glib_mem_vtable.try_realloc (mem, n_bytes);

    if (mem)
        glib_mem_vtable.free (mem);

    return NULL;
}
Beispiel #3
0
/**
 * g_try_realloc:
 * @mem: (allow-none): previously-allocated memory, or %NULL.
 * @n_bytes: number of bytes to allocate.
 * 
 * Attempts to realloc @mem to a new size, @n_bytes, and returns %NULL
 * on failure. Contrast with g_realloc(), which aborts the program
 * on failure. If @mem is %NULL, behaves the same as g_try_malloc().
 * 
 * Returns: the allocated memory, or %NULL.
 */
gpointer
g_try_realloc (gpointer mem,
	       gsize    n_bytes)
{
  gpointer newmem;

  if (G_LIKELY (n_bytes))
    newmem = glib_mem_vtable.try_realloc (mem, n_bytes);
  else
    {
      newmem = NULL;
      if (mem)
	glib_mem_vtable.free (mem);
    }

  TRACE (GLIB_MEM_REALLOC((void*) newmem, (void*)mem, (unsigned int) n_bytes, 1));

  return newmem;
}