LibreOffice
LibreOffice 6.2 SDK C/C++ API Reference
Macros | Typedefs | Functions
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 SAL_DLLPUBLIC_RTTI rtl_arena_st rtl_arena_type
 Opaque rtl_arena_type. More...
 
typedef struct rtl_cache_st rtl_cache_type
 Opaque rtl_cache_type. More...
 

Functions

SAL_DLLPUBLIC void * rtl_allocateMemory (sal_Size Bytes) SAL_THROW_EXTERN_C()
 Allocate memory. More...
 
SAL_DLLPUBLIC void * rtl_reallocateMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
 Reallocate memory. More...
 
SAL_DLLPUBLIC void rtl_freeMemory (void *Ptr) SAL_THROW_EXTERN_C()
 Free memory. More...
 
SAL_DLLPUBLIC void * rtl_allocateZeroMemory (sal_Size Bytes) SAL_THROW_EXTERN_C()
 Allocate and zero memory. More...
 
SAL_DLLPUBLIC void rtl_secureZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
 Zero memory. More...
 
SAL_DLLPUBLIC void rtl_freeZeroMemory (void *Ptr, sal_Size Bytes) SAL_THROW_EXTERN_C()
 Zero and free memory. More...
 
SAL_DLLPUBLIC void * rtl_allocateAlignedMemory (sal_Size Alignment, sal_Size Bytes) SAL_THROW_EXTERN_C()
 Allocate aligned memory. More...
 
SAL_DLLPUBLIC void rtl_freeAlignedMemory (void *Ptr) SAL_THROW_EXTERN_C()
 Free memory allocated with rtl_allocateAlignedMemory(). More...
 
SAL_DLLPUBLIC rtl_arena_typertl_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_typertl_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()
 

Macro Definition Documentation

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

Typedef Documentation

typedef struct SAL_DLLPUBLIC_RTTI rtl_arena_st rtl_arena_type

Opaque rtl_arena_type.

typedef struct rtl_cache_st rtl_cache_type

Opaque rtl_cache_type.

Function Documentation

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]Alignmentalignment in bytes, must be a power of two multiple of sizeof(void*).
[in]Bytesmemory size.
Returns
pointer to the allocated memory.
Since
LibreOffice 4.3
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]Bytesmemory size.
Returns
pointer to the allocated memory.
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]Bytesmemory size.
Returns
pointer to the allocated and zero'ed memory.
SAL_DLLPUBLIC void* rtl_arena_alloc ( rtl_arena_type pArena,
sal_Size *  pBytes 
)
Parameters
[in]pArenaarena from which resource is allocated.
[in,out]pBytessize of resource to allocate.
Returns
allocated resource, or NULL upon failure.
See also
rtl_arena_free()
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 *(*)(rtl_arena_type *, sal_Size *)  source_alloc,
void(*)(rtl_arena_type *, void *, sal_Size)  source_free,
int  nFlags 
)
Parameters
[in]pNamedescriptive name; for debugging purposes.
[in]quantumresource allocation unit / granularity; rounded up to next power of 2.
[in]quantum_cache_maxno longer used, should be 0.
[in]source_arenapassed as argument to source_alloc, source_free; usually NULL.
[in]source_allocfunction to allocate resources; usually rtl_arena_alloc.
[in]source_freefunction to free resources; usually rtl_arena_free.
[in]nFlagsflags; usually 0.
Returns
pointer to rtl_arena_type, or NULL upon failure.
See also
rtl_arena_destroy()
SAL_DLLPUBLIC void rtl_arena_destroy ( rtl_arena_type pArena)
Parameters
[in]pArenathe arena to destroy.
Returns
None
See also
rtl_arena_create()
SAL_DLLPUBLIC void rtl_arena_free ( rtl_arena_type pArena,
void *  pAddr,
sal_Size  nBytes 
)
Parameters
[in]pArenaarena from which resource was allocated.
[in]pAddrresource to free.
[in]nBytessize of resource.
Returns
None.
See also
rtl_arena_alloc()
SAL_DLLPUBLIC void* rtl_cache_alloc ( rtl_cache_type pCache)
Parameters
[in]pCachecache from which object is allocated.
Returns
pointer to the allocated object, or NULL upon failure.
SAL_DLLPUBLIC rtl_cache_type* rtl_cache_create ( const char *  pName,
sal_Size  nObjSize,
sal_Size  nObjAlign,
int(*)(void *pObj, void *pUserArg)  constructor,
void(*)(void *pObj, void *pUserArg)  destructor,
void(*)(void *pUserArg)  reclaim,
void *  pUserArg,
rtl_arena_type pSource,
int  nFlags 
)
Parameters
[in]pNamedescriptive name; for debugging purposes.
[in]nObjSizeobject size.
[in]nObjAlignobject alignment; usually 0 for suitable default.
[in]constructorobject constructor callback function; returning 1 for success or 0 for failure.
[in]destructorobject destructor callback function.
[in]reclaimreclaim callback function.
[in]pUserArgopaque argument passed to callback functions.
[in]pSourceunused argument (should be null).
[in]nFlagsflags (unused).
Returns
pointer to rtl_cache_type, or NULL upon failure.
See also
rtl_cache_destroy()
SAL_DLLPUBLIC void rtl_cache_destroy ( rtl_cache_type pCache)
Parameters
[in]pCachethe cache to destroy.
Returns
None.
See also
rtl_cache_create()
SAL_DLLPUBLIC void rtl_cache_free ( rtl_cache_type pCache,
void *  pObj 
)
Parameters
[in]pCachecache from which object was allocated.
[in]pObjobject to free.
Returns
None.
See also
rtl_cache_alloc()
SAL_DLLPUBLIC void rtl_freeAlignedMemory ( void *  Ptr)

Free memory allocated with rtl_allocateAlignedMemory().

Parameters
[in]Ptrpointer to the previously allocated memory.
Returns
none. Memory is released. Ptr is invalid.
Since
LibreOffice 4.3
SAL_DLLPUBLIC void rtl_freeMemory ( void *  Ptr)

Free memory.

Parameters
[in]Ptrpointer to the previously allocated memory.
Returns
none. Memory is released. Ptr is invalid.
SAL_DLLPUBLIC void rtl_freeZeroMemory ( void *  Ptr,
sal_Size  Bytes 
)

Zero and free memory.

Parameters
[in]Ptrpointer to the previously allocated memory.
[in]Bytesmemory size.
Returns
none. Memory is zero'ed with rtl_secureZeroMemory() and released. Ptr is invalid.
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]Ptrpointer to the previously allocated memory.
[in]Bytesnew memory size.
Returns
pointer to the reallocated memory. May differ from Ptr.
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]Ptrpointer to the previously allocated memory.
[in]Bytesmemory size.
Since
LibreOffice 5.0