MOS Source Code
Loading...
Searching...
No Matches
malloc_wrappers.c File Reference
#include "malloc_wrappers.h"
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
+ Include dependency graph for malloc_wrappers.c:

Go to the source code of this file.

Macros

#define GUARD_SIZE   (sizeof(size_t)*3)
 
#define PREFIX_SIZE   (sizeof(size_t)*2)
 
#define CHECK1   ((size_t)0xDEADBEEF)
 
#define CHECK2   ((size_t)0x600DCAFE)
 
#define MAX_ALLOC_BYTES   16*1024*1024
 
#define DEBUG_MALLOC   0
 

Functions

static size_t round_blocksize (size_t size)
 
voidmalloc_with_check (size_t size)
 
void free_with_check (void *mem)
 
voidrealloc_with_check (void *ptr, size_t size)
 
size_t get_alloc_count ()
 
size_t get_allocation_size (const void *mem)
 
size_t get_alloc_bytes ()
 
void set_max_alloc_bytes (size_t max_bytes)
 
size_t get_max_alloc_bytes ()
 

Variables

static size_t g_alloc_count = 0
 
static size_t g_alloc_bytes = 0
 
static size_t g_max_alloc_bytes = 16*1024*1024
 

Macro Definition Documentation

◆ GUARD_SIZE

#define GUARD_SIZE   (sizeof(size_t)*3)

Definition at line 12 of file malloc_wrappers.c.

Referenced by malloc_with_check(), and realloc_with_check().

◆ PREFIX_SIZE

#define PREFIX_SIZE   (sizeof(size_t)*2)

◆ CHECK1

#define CHECK1   ((size_t)0xDEADBEEF)

Definition at line 14 of file malloc_wrappers.c.

Referenced by free_with_check(), malloc_with_check(), and realloc_with_check().

◆ CHECK2

#define CHECK2   ((size_t)0x600DCAFE)

Definition at line 15 of file malloc_wrappers.c.

Referenced by free_with_check(), malloc_with_check(), and realloc_with_check().

◆ MAX_ALLOC_BYTES

#define MAX_ALLOC_BYTES   16*1024*1024

Definition at line 18 of file malloc_wrappers.c.

◆ DEBUG_MALLOC

#define DEBUG_MALLOC   0

Definition at line 22 of file malloc_wrappers.c.

Referenced by free_with_check(), malloc_with_check(), and realloc_with_check().

Function Documentation

◆ round_blocksize()

static size_t round_blocksize ( size_t size)
static

Definition at line 47 of file malloc_wrappers.c.

Referenced by malloc_with_check(), and realloc_with_check().

◆ malloc_with_check()

void * malloc_with_check ( size_t size)

◆ free_with_check()

◆ realloc_with_check()

void * realloc_with_check ( void * ptr,
size_t size )

Definition at line 101 of file malloc_wrappers.c.

+ Here is the call graph for this function:

◆ get_alloc_count()

◆ get_allocation_size()

size_t get_allocation_size ( const void * mem)

Definition at line 168 of file malloc_wrappers.c.

Referenced by validate_pointer().

◆ get_alloc_bytes()

size_t get_alloc_bytes ( )

Definition at line 175 of file malloc_wrappers.c.

Referenced by do_roundtrips().

◆ set_max_alloc_bytes()

void set_max_alloc_bytes ( size_t max_bytes)

Definition at line 181 of file malloc_wrappers.c.

Referenced by do_roundtrips(), and main().

◆ get_max_alloc_bytes()

size_t get_max_alloc_bytes ( )

Definition at line 186 of file malloc_wrappers.c.

Referenced by do_roundtrips().

Variable Documentation

◆ g_alloc_count

size_t g_alloc_count = 0
static

◆ g_alloc_bytes

size_t g_alloc_bytes = 0
static

◆ g_max_alloc_bytes

size_t g_max_alloc_bytes = 16*1024*1024
static