Esempio n. 1
0
static void
bastile_secure_buffer_finalize (GObject *obj)
{
	BastileSecureBuffer *self = BASTILE_SECURE_BUFFER (obj);
	BastileSecureBufferPrivate *pv = self->priv;

	if (pv->text) {
		mate_keyring_memory_free (pv->text);
		pv->text = NULL;
		pv->text_bytes = pv->text_size = 0;
		pv->text_chars = 0;
	}

	G_OBJECT_CLASS (bastile_secure_buffer_parent_class)->finalize (obj);
}
/**
 * mate_keyring_memory_try_realloc:
 * @p: The pointer to reallocate or NULL to allocate a new block.
 * @sz: The new desired size of the memory block.
 *
 * Reallocate a block of mate-keyring non-pageable memory.
 *
 * Glib memory is also reallocated correctly when passed to this function.
 * If called with a null pointer, then a new block of memory is allocated.
 * If called with a zero size, then the block of memory is freed.
 *
 * If memory cannot be allocated, NULL is returned and the original block
 * of memory remains intact.
 *
 * Return value: The new block, or NULL if memory cannot be allocated.
 * The memory block should be freed with mate_keyring_memory_free()
 */
gpointer
mate_keyring_memory_try_realloc (gpointer p, gulong sz)
{
	gpointer n;

	if (!p) {
		return mate_keyring_memory_try_alloc (sz);
	} else if (!sz) {
		 mate_keyring_memory_free (p);
		 return NULL;
	} else if (!egg_secure_check (p)) {
		return g_try_realloc (p, sz);
	}

	/* First try and ask secure memory to reallocate */
	n = egg_secure_realloc_full (p, sz, 0);

	g_assert (n);

	return n;
}