|  |  |  | Gcr Library Reference Manual |  | 
|---|---|---|---|---|
| Top | Description | ||||
#define gcr_secure_memory_new (type, n_objects) gpointer gcr_secure_memory_alloc (gsize size); gpointer gcr_secure_memory_try_alloc (gsize size); gpointer gcr_secure_memory_realloc (gpointer memory,gsize size); gpointer gcr_secure_memory_try_realloc (gpointer memory,gsize size); gchar * gcr_secure_memory_strdup (const gchar *string); void gcr_secure_memory_strfree (gchar *string); void gcr_secure_memory_free (gpointer memory); gboolean gcr_secure_memory_is_secure (gpointer memory);
Normal allocated memory can be paged to disk at the whim of the operating system. This can be a problem for sensitive information like passwords, keys and secrets.
The Gcr library holds passwords and keys in non-pageable, or locked memory. This is only possible if the OS contains support for it.
These functions allow applications to use secure memory to hold passwords and other sensitive information.
#define gcr_secure_memory_new(type, n_objects)
Allocate objects in non-pageable memory.
| 
 | C type of the objects to allocate | 
| 
 | number of objects to allocate | 
| Returns : | the new block of memory. [transfer full] | 
gpointer            gcr_secure_memory_alloc             (gsize size);
Allocate a block of non-pageable memory.
If non-pageable memory cannot be allocated then normal memory will be returned.
| 
 | The new desired size of the memory block. | 
| Returns : | new memory block which should be freed
with gcr_secure_memory_free(). [transfer full] | 
gpointer            gcr_secure_memory_try_alloc         (gsize size);
Allocate a block of non-pageable memory.
If non-pageable memory cannot be allocated, then NULL is returned.
| 
 | new desired size of the memory block | 
| Returns : | new block, or NULLif memory cannot be
allocated; memory block should be freed withgcr_secure_memory_free(). [transfer full] | 
gpointer gcr_secure_memory_realloc (gpointer memory,gsize size);
Reallocate a block of non-pageable memory.
Glib memory is also reallocated correctly. 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 non-pageable memory cannot be allocated then normal memory will be returned.
| 
 | pointer to reallocate or NULLto allocate a new block. [allow-none] | 
| 
 | new desired size of the memory block, or 0 to free the memory | 
| Returns : | new block, or NULLif the block was
freed; memory block should be freed withgcr_secure_memory_free(). [transfer full] | 
gpointer gcr_secure_memory_try_realloc (gpointer memory,gsize size);
Reallocate a block of 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.
| 
 | pointer to reallocate or NULLto allocate a new block. [allow-none] | 
| 
 | new desired size of the memory block | 
| Returns : | the new block, or NULLif memory cannot be
allocated; the memory block should be freed withgcr_secure_memory_free(). [transfer full] | 
gchar *             gcr_secure_memory_strdup            (const gchar *string);
Copy a string into non-pageable memory. If the input string is NULL, then
NULL will be returned.
| 
 | null terminated string to copy. [allow-none] | 
| Returns : | copied string, should be freed with gcr_secure_memory_free() | 
void                gcr_secure_memory_strfree           (gchar *string);
Free a string, whether securely allocated using these functions or not. This will also clear out the contents of the string so they do not remain in memory.
| 
 | null terminated string to fere. [allow-none] | 
void                gcr_secure_memory_free              (gpointer memory);
Free a block of non-pageable memory.
Glib memory is also freed correctly when passed to this function. If called
with a NULL pointer then no action is taken.
| 
 | pointer to the beginning of the block of memory to free. [allow-none] |