| Wireshark 4.7.0 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions
wmem_core.h File Reference
`#include <stdint.h>`
`#include <stdbool.h>`
`#include <string.h>`
`#include <glib.h>`
`#include <ws_symbol_export.h>`
`#include <ws_attributes.h>`
`#include <ws_posix_compat.h>`

Go to the source code of this file.

## Macros
#define | wmem_new(allocator, type) ((type*)wmem_alloc((allocator), sizeof(type)))
| Allocate memory sufficient to hold one object of the given type.
#define | wmem_safe_mult_type_size(type, num) ((((num) <= 0) || ((size_t)sizeof(type) > (G_MAXSSIZE / (size_t)(num)))) ? 0 : (sizeof(type) * (num)))
| Overflow-safe multiplication of the size of a type by a number of items.
#define | wmem_alloc_array(allocator, type, num) ((type*)wmem_alloc((allocator), wmem_safe_mult_type_size(type, (num))))
| Allocate memory sufficient to hold n objects of the given type.
#define | wmem_new0(allocator, type) ((type*)wmem_alloc0((allocator), sizeof(type)))
| Allocate memory sufficient to hold one object of the given type. Initializes the allocated memory with zeroes.
#define | wmem_alloc0_array(allocator, type, num) ((type*)wmem_alloc0((allocator), wmem_safe_mult_type_size(type, (num))))
| Allocate memory sufficient to hold n objects of the given type. Initializes the allocated memory with zeroes.

## Typedefs
typedef struct _wmem_allocator_t | wmem_allocator_t
typedef enum _wmem_allocator_type_t | wmem_allocator_type_t

## Enumerations
enum | _wmem_allocator_type_t { WMEM_ALLOCATOR_SIMPLE , WMEM_ALLOCATOR_BLOCK , WMEM_ALLOCATOR_STRICT , WMEM_ALLOCATOR_BLOCK_FAST }

## Functions
WS_WARN_UNUSED WS_DLL_PUBLIC void * | wmem_alloc (wmem_allocator_t *allocator, const size_t size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(2)
| Allocate the requested amount of memory in the given pool.
WS_WARN_UNUSED WS_DLL_PUBLIC void * | wmem_alloc0 (wmem_allocator_t *allocator, const size_t size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(2)
| Allocate the requested amount of memory in the given pool. Initializes the allocated memory with zeroes.
WS_DLL_PUBLIC void | wmem_free (wmem_allocator_t *allocator, void *ptr)
| Returns the allocated memory to the allocator.
WS_WARN_UNUSED WS_DLL_PUBLIC void * | wmem_realloc (wmem_allocator_t *allocator, void *ptr, const size_t size) G_GNUC_ALLOC_SIZE(3)
| Resizes a block of memory, potentially moving it if resizing it in place is not possible.
WS_DLL_PUBLIC void | wmem_free_all (wmem_allocator_t *allocator)
| Frees all the memory allocated in a pool.
WS_DLL_PUBLIC void | wmem_gc (wmem_allocator_t *allocator)
| Triggers a garbage-collection in the allocator.
WS_DLL_PUBLIC void | wmem_destroy_allocator (wmem_allocator_t *allocator)
| Destroy the given allocator, freeing all memory allocated in it.
WS_DLL_PUBLIC wmem_allocator_t * | wmem_allocator_new (const wmem_allocator_type_t type)
| Create a new allocator of the given type.
WS_DLL_PUBLIC void | wmem_init (void)
| Initialize the wmem subsystem.
WS_DLL_PUBLIC void | wmem_cleanup (void)
| Teardown the wmem subsystem.
WS_DLL_PUBLIC void | wmem_enter_scope (wmem_allocator_t *allocator)
| Mark an allocator as entering a scoped memory region.
WS_DLL_PUBLIC void | wmem_leave_scope (wmem_allocator_t *allocator)
| Exit a scoped memory region and free all scoped allocations.
WS_DLL_PUBLIC bool | wmem_in_scope (wmem_allocator_t *allocator)
| Check whether an allocator is currently in a scoped region.

## Detailed Description

Definitions for the Wireshark Memory Manager Core Copyright 2012, Evan Huus eapac.nosp@m.he@g.nosp@m.mail..nosp@m.com

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later