## Non-pageable Memory

Non-pageable Memory — Secure Non-pageable Memory

## Functions

#define | gnome_keyring_memory_new()
gpointer | gnome_keyring_memory_alloc ()
gpointer | gnome_keyring_memory_try_alloc ()
gpointer | gnome_keyring_memory_realloc ()
gpointer | gnome_keyring_memory_try_realloc ()
void | gnome_keyring_memory_free ()
gboolean | gnome_keyring_memory_is_secure ()
gchar * | gnome_keyring_memory_strdup ()

## Description

All of these APIs are deprecated. Use libsecret instead.

Normal allocated memory can be paged to disk at the whim of the operating system. This can be a serious problem for sensitive information like passwords, keys and secrets.

GNOME Keyring holds passwords in non-pageable, or locked memory. This happens both in the daemon and in the library. This is only possible if the OS contains support for it.

These functions allow applications to use to hold passwords and other sensitive information.

## Functions

### gnome_keyring_memory_new()

    #define             gnome_keyring_memory_new(type, n_objects)

`gnome_keyring_memory_new` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_alloc()` instead.

Allocate objects in non-pageable gnome-keyring memory.

#### Parameters

type | The C type of the objects to allocate |
n_objects | The number of objects to allocate. |

#### Returns

The new block of memory.

### gnome_keyring_memory_alloc ()

    gpointer
    gnome_keyring_memory_alloc (gulong sz);

`gnome_keyring_memory_alloc` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_alloc()` instead.

Allocate a block of gnome-keyring non-pageable memory.

If non-pageable memory cannot be allocated then normal memory will be returned.

#### Parameters

sz | The new desired size of the memory block. |

#### Returns

The new memory block which should be freed with `gnome_keyring_memory_free()`.

[transfer full]

### gnome_keyring_memory_try_alloc ()

    gpointer
    gnome_keyring_memory_try_alloc (gulong sz);

`gnome_keyring_memory_try_alloc` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_try_alloc()` instead.

Allocate a block of gnome-keyring non-pageable memory.

If non-pageable memory cannot be allocated, then `NULL` is returned.

#### Parameters

sz | The new desired size of the memory block. |

#### Returns

The new block, or `NULL` if memory cannot be allocated. The memory block should be freed with `gnome_keyring_memory_free()`.

[transfer full]

### gnome_keyring_memory_realloc ()

    gpointer
    gnome_keyring_memory_realloc (gpointer p,
                                  gulong sz);

`gnome_keyring_memory_realloc` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_realloc()` instead.

Reallocate a block of gnome-keyring 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.

#### Parameters

p | The pointer to reallocate or `NULL` to allocate a new block. | [allow-none]
sz | The new desired size of the memory block, or 0 to free the memory. |

#### Returns

The new block, or `NULL` if the block was freed. The memory block should be freed with `gnome_keyring_memory_free()`.

[transfer full]

### gnome_keyring_memory_try_realloc ()

    gpointer
    gnome_keyring_memory_try_realloc (gpointer p,
                                      gulong sz);

`gnome_keyring_memory_try_realloc` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_try_realloc()` instead.

Reallocate a block of gnome-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.

#### Parameters

p | The pointer to reallocate or `NULL` to allocate a new block. | [allow-none]
sz | The new desired size of the memory block. |

#### Returns

The new block, or `NULL` if memory cannot be allocated. The memory block should be freed with `gnome_keyring_memory_free()`.

[transfer full]

### gnome_keyring_memory_free ()

    void
    gnome_keyring_memory_free (gpointer p);

`gnome_keyring_memory_free` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_free()` instead.

Free a block of gnome-keyring 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.

#### Parameters

p | The pointer to the beginning of the block of memory to free. |

### gnome_keyring_memory_is_secure ()

    gboolean
    gnome_keyring_memory_is_secure (gpointer p);

`gnome_keyring_memory_is_secure` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_is_secure()` instead.

Check if a pointer is in non-pageable memory allocated by gnome-keyring.

#### Parameters

p | The pointer to check |

#### Returns

Whether the memory is non-pageable or not

### gnome_keyring_memory_strdup ()

    gchar *
    gnome_keyring_memory_strdup (const gchar *str);

`gnome_keyring_memory_strdup` is deprecated and should not be used in newly-written code.

Use `gcr_secure_memory_strdup()` instead.

Copy a string into non-pageable memory. If the input string is `NULL`, then `NULL` will be returned.

#### Parameters

str | The null terminated string to copy |

#### Returns

The copied string, should be freed with `gnome_keyring_memory_free()`

## Types and Values