liboom 1.0.1
Debugging helper library with Memory leak detection
oomstub.h File Reference

C memory management diverters. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void oomstub_setcountdown (const int counter)
 Sets the malloc countdown before triggering a failure. More...
 
int oomstub_getcountdown ()
 Gets the current malloc countdown before triggering a failure. More...
 

Detailed Description

C memory management diverters.

This file implements fake malloc, free and realloc functions which can fail and simulate OOM after a countdown. This library is not threadsafe. Inspired from https://github.com/bkthomps/Containers test suite

assert(NULL!=malloc(123)); // Success
assert(NULL!=realloc(oldptr,123)); // Success
assert(NULL==malloc(123)); // Failure with NULL
assert(NULL!=malloc(123)); // Success
assert(NULL!=malloc(123)); // Success
void * realloc(void *ptr, size_t new_size)
stdc realloc stub function
Definition: oomstub.c:153
void * malloc(size_t size)
stdc malloc stub function
Definition: oomstub.c:87
void oomstub_setcountdown(const int counter)
Sets the malloc countdown before triggering a failure.
Definition: oomstub.c:62
Author
François Cerbelle (Fanfan), franc.nosp@m.ois@.nosp@m.cerbe.nosp@m.lle..nosp@m.net

Definition in file oomstub.h.

Function Documentation

◆ oomstub_getcountdown()

int oomstub_getcountdown ( )

Gets the current malloc countdown before triggering a failure.

Returns
The current internal countdown value
See also
malloc
calloc
realloc

Definition at line 72 of file oomstub.c.

◆ oomstub_setcountdown()

void oomstub_setcountdown ( const int  counter)

Sets the malloc countdown before triggering a failure.

Parameters
counterValue to set in the internal countdown
See also
malloc
calloc
realloc

Definition at line 62 of file oomstub.c.