Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Functions
wmem_allocator_strict.h File Reference
#include "wmem_core.h"

Go to the source code of this file.

Functions

void wmem_strict_allocator_init (wmem_allocator_t *allocator)
 Initialize a strict memory allocator.
 
void wmem_strict_check_canaries (wmem_allocator_t *allocator)
 Verify memory canaries for a strict allocator.
 

Detailed Description

Definitions for the Wireshark Memory Manager Strict Allocator 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

Function Documentation

◆ wmem_strict_allocator_init()

void wmem_strict_allocator_init ( wmem_allocator_t allocator)

Initialize a strict memory allocator.

Sets up a wmem_allocator_t to use a strict allocation strategy that enforces tighter control over memory usage. In this allocator, we do everything we can to catch invalid memory accesses. This includes using canaries (what Valgrind calls redzones) and filling allocated and freed memory with garbage. Valgrind is still the better tool on the platforms where it is available - use it instead if possible.

Initializes function pointers for allocation, reallocation, freeing, and cleanup, and sets up internal block tracking.

Parameters
allocatorPointer to the allocator structure to initialize.
Note
After initialization, the allocator can be used for strict memory operations. The allocator must not be NULL.

◆ wmem_strict_check_canaries()

void wmem_strict_check_canaries ( wmem_allocator_t allocator)

Verify memory canaries for a strict allocator.

Performs integrity checks on all memory blocks managed by a strict allocator by validating their canary values. This helps detect memory corruption such as buffer overflows or underflows.

This function only operates if the allocator's type is WMEM_ALLOCATOR_STRICT. If the allocator is not of this type, the function returns immediately.

Parameters
allocatorPointer to the strict memory allocator to check.
Note
This function is typically used for debugging or validating memory safety.