LibreOffice: rtl/alloc.h File Reference

LibreOffice LibreOffice 26.2 SDK C/C++ API Reference

Loading...
Searching...
No Matches
alloc.h File Reference
`#include "sal/config.h"`
`#include "sal/saldllapi.h"`
`#include "sal/types.h"`

Go to the source code of this file.

## Macros
#define | RTL_ARENA_NAME_LENGTH 31
#define | RTL_CACHE_NAME_LENGTH 31
#define | RTL_CACHE_FLAG_BULKDESTROY 1 /* obsolete */

## Typedefs
typedef struct rtl_arena_st | rtl_arena_type
typedef struct rtl_cache_st | rtl_cache_type
| Opaque rtl_cache_type.

## Functions
SAL_DLLPUBLIC void * | rtl_allocateMemory (sal_Size Bytes) SAL_THROW_EXTERN_C()
| Allocate memory.
SAL_DLLPUBLIC void * | rtl_reallocateMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
| Reallocate memory.
SAL_DLLPUBLIC void | rtl_freeMemory (void *Ptr) SAL_THROW_EXTERN_C()
| Free memory.
SAL_DLLPUBLIC void * | rtl_allocateZeroMemory (sal_Size Bytes) SAL_THROW_EXTERN_C()
| Allocate and zero memory.
SAL_DLLPUBLIC void | rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
| Zero memory.
SAL_DLLPUBLIC void | rtl_freeZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
| Zero and free memory.
SAL_DLLPUBLIC void * | rtl_allocateAlignedMemory (sal_Size Alignment, sal_Size Bytes) SAL_THROW_EXTERN_C()
| Allocate aligned memory.
SAL_DLLPUBLIC void | rtl_freeAlignedMemory (void *Ptr) SAL_THROW_EXTERN_C()
| Free memory allocated with rtl_allocateAlignedMemory().
SAL_DLLPUBLIC rtl_arena_type * | rtl_arena_create (const char *pName, sal_Size quantum, sal_Size quantum_cache_max, rtl_arena_type *source_arena, void *(*source_alloc)(rtl_arena_type *, sal_Size *), void(*source_free)(rtl_arena_type *, void *, sal_Size), int nFlags) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void | rtl_arena_destroy (rtl_arena_type *pArena) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void * | rtl_arena_alloc (rtl_arena_type *pArena, sal_Size *pBytes) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void | rtl_arena_free (rtl_arena_type *pArena, void *pAddr, sal_Size nBytes) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC rtl_cache_type * | rtl_cache_create (const char *pName, sal_Size nObjSize, sal_Size nObjAlign, int(*constructor)(void *pObj, void *pUserArg), void(*destructor)(void *pObj, void *pUserArg), void(*reclaim)(void *pUserArg), void *pUserArg, rtl_arena_type *pSource, int nFlags) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void | rtl_cache_destroy (rtl_cache_type *pCache) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void * | rtl_cache_alloc (rtl_cache_type *pCache) SAL_THROW_EXTERN_C()
SAL_DLLPUBLIC void | rtl_cache_free (rtl_cache_type *pCache, void *pObj) SAL_THROW_EXTERN_C()

## Variables
struct SAL_DLLPUBLIC_RTTI | rtl_arena_st
| Opaque rtl_arena_type.

## Macro Definition Documentation

## ◆ RTL_ARENA_NAME_LENGTH

#define RTL_ARENA_NAME_LENGTH 31

## ◆ RTL_CACHE_FLAG_BULKDESTROY

#define RTL_CACHE_FLAG_BULKDESTROY 1 /* obsolete */

## ◆ RTL_CACHE_NAME_LENGTH

#define RTL_CACHE_NAME_LENGTH 31

## Typedef Documentation

## ◆ rtl_arena_type

typedef struct rtl_arena_st rtl_arena_type

## ◆ rtl_cache_type

typedef struct rtl_cache_st rtl_cache_type

Opaque rtl_cache_type.

## Function Documentation

## ◆ rtl_allocateAlignedMemory()

SAL_DLLPUBLIC void * rtl_allocateAlignedMemory | ( | sal_Size | Alignment,
|  | sal_Size | Bytes )

Allocate aligned memory.

A call to this function will return NULL upon the requested memory size being either zero or larger than currently allocatable.

Memory obtained through this function must be freed with rtl_freeAlignedMemory().

Parameters

  [in] | Alignment | alignment in bytes, must be a power of two multiple of sizeof(void*).
  [in] | Bytes | memory size.

Returns
  pointer to the allocated memory.

Since
  LibreOffice 4.3

## ◆ rtl_allocateMemory()

SAL_DLLPUBLIC void * rtl_allocateMemory | ( | sal_Size | Bytes | ) |

Allocate memory.

A call to this function will return NULL upon the requested memory size being either zero or larger than currently allocatable.

Parameters

  [in] | Bytes | memory size.

Returns
  pointer to the allocated memory.

## ◆ rtl_allocateZeroMemory()

SAL_DLLPUBLIC void * rtl_allocateZeroMemory | ( | sal_Size | Bytes | ) |

Allocate and zero memory.

A call to this function will return NULL upon the requested memory size being either zero or larger than currently allocatable.

Parameters

  [in] | Bytes | memory size.

Returns
  pointer to the allocated and zero'ed memory.

## ◆ rtl_arena_alloc()

SAL_DLLPUBLIC void * rtl_arena_alloc | ( | rtl_arena_type * | pArena,
|  | sal_Size * | pBytes )

Parameters

  [in] | pArena | arena from which resource is allocated.
  [in,out] | pBytes | size of resource to allocate.

Returns
  allocated resource, or NULL upon failure.

See also
  rtl_arena_free()

## ◆ rtl_arena_create()

SAL_DLLPUBLIC rtl_arena_type * rtl_arena_create | ( | const char * | pName,
|  | sal_Size | quantum,
|  | sal_Size | quantum_cache_max,
|  | rtl_arena_type * | source_arena,
|  | void *(* | source_alloc )(rtl_arena_type *, sal_Size *),
|  | void(* | source_free )(rtl_arena_type *, void *, sal_Size),
|  | int | nFlags )

Parameters

  [in] | pName | descriptive name; for debugging purposes.
  [in] | quantum | resource allocation unit / granularity; rounded up to next power of 2.
  [in] | quantum_cache_max | no longer used, should be 0.
  [in] | source_arena | passed as argument to source_alloc, source_free; usually NULL.
  [in] | source_alloc | function to allocate resources; usually rtl_arena_alloc.
  [in] | source_free | function to free resources; usually rtl_arena_free.
  [in] | nFlags | flags; usually 0.

Returns
  pointer to rtl_arena_type, or NULL upon failure.

See also
  rtl_arena_destroy()

## ◆ rtl_arena_destroy()

SAL_DLLPUBLIC void rtl_arena_destroy | ( | rtl_arena_type * | pArena | ) |

Parameters

  [in] | pArena | the arena to destroy.

See also
  rtl_arena_create()

## ◆ rtl_arena_free()

SAL_DLLPUBLIC void rtl_arena_free | ( | rtl_arena_type * | pArena,
|  | void * | pAddr,
|  | sal_Size | nBytes )

Parameters

  [in] | pArena | arena from which resource was allocated.
  [in] | pAddr | resource to free.
  [in] | nBytes | size of resource.

See also
  rtl_arena_alloc()

## ◆ rtl_cache_alloc()

SAL_DLLPUBLIC void * rtl_cache_alloc | ( | rtl_cache_type * | pCache | ) |

Parameters

  [in] | pCache | cache from which object is allocated.

Returns
  pointer to the allocated object, or NULL upon failure.

## ◆ rtl_cache_create()

SAL_DLLPUBLIC rtl_cache_type * rtl_cache_create | ( | const char * | pName,
|  | sal_Size | nObjSize,
|  | sal_Size | nObjAlign,
|  | int(* | constructor )(void *pObj, void *pUserArg),
|  | void(* | destructor )(void *pObj, void *pUserArg),
|  | void(* | reclaim )(void *pUserArg),
|  | void * | pUserArg,
|  | rtl_arena_type * | pSource,
|  | int | nFlags )

Parameters

  [in] | pName | descriptive name; for debugging purposes.
  [in] | nObjSize | object size.
  [in] | nObjAlign | object alignment; usually 0 for suitable default.
  [in] | constructor | object constructor callback function; returning 1 for success or 0 for failure.
  [in] | destructor | object destructor callback function.
  [in] | reclaim | reclaim callback function.
  [in] | pUserArg | opaque argument passed to callback functions.
  [in] | pSource | unused argument (should be null).
  [in] | nFlags | flags (unused).

Returns
  pointer to rtl_cache_type, or NULL upon failure.

See also
  rtl_cache_destroy()

## ◆ rtl_cache_destroy()

SAL_DLLPUBLIC void rtl_cache_destroy | ( | rtl_cache_type * | pCache | ) |

Parameters

  [in] | pCache | the cache to destroy.

See also
  rtl_cache_create()

## ◆ rtl_cache_free()

SAL_DLLPUBLIC void rtl_cache_free | ( | rtl_cache_type * | pCache,
|  | void * | pObj )

Parameters

  [in] | pCache | cache from which object was allocated.
  [in] | pObj | object to free.

See also
  rtl_cache_alloc()

## ◆ rtl_freeAlignedMemory()

SAL_DLLPUBLIC void rtl_freeAlignedMemory | ( | void * | Ptr | ) |

Free memory allocated with rtl_allocateAlignedMemory().

Memory is released, and the pointer invalidated.

Parameters

  [in] | Ptr | pointer to the previously allocated memory.

Since
  LibreOffice 4.3

## ◆ rtl_freeMemory()

SAL_DLLPUBLIC void rtl_freeMemory | ( | void * | Ptr | ) |

Free memory.

Memory is released, and the pointer is invalidated.

Parameters

  [in] | Ptr | pointer to the previously allocated memory.

## ◆ rtl_freeZeroMemory()

SAL_DLLPUBLIC void rtl_freeZeroMemory | ( | void * | Ptr,
|  | sal_Size | Bytes )

Zero and free memory.

Memory is zero'ed with rtl_secureZeroMemory() and released. The original pointer is no longer valid.

Parameters

  [in] | Ptr | pointer to the previously allocated memory.
  [in] | Bytes | memory size.

## ◆ rtl_reallocateMemory()

SAL_DLLPUBLIC void * rtl_reallocateMemory | ( | void * | Ptr,
|  | sal_Size | Bytes )

Reallocate memory.

A call to this function with parameter 'Ptr' being NULL is equivalent to a rtl_allocateMemory() call. A call to this function with parameter 'Bytes' being 0 is equivalent to a rtl_freeMemory() call.

See also
  rtl_allocateMemory()
  rtl_freeMemory()

Parameters

  [in] | Ptr | pointer to the previously allocated memory.
  [in] | Bytes | new memory size.

Returns
  pointer to the reallocated memory. May differ from Ptr.

## ◆ rtl_secureZeroMemory()

SAL_DLLPUBLIC void rtl_secureZeroMemory | ( | void * | Ptr,
|  | sal_Size | Bytes )

Zero memory.

Fills a block of memory with zeros in a way that is guaranteed to be secure

Parameters

  [in] | Ptr | pointer to the previously allocated memory.
  [in] | Bytes | memory size.

Since
  LibreOffice 5.0

## Variable Documentation

## ◆ rtl_arena_st

struct SAL_DLLPUBLIC_RTTI rtl_arena_st

Opaque rtl_arena_type.