Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
Loading...
Searching...
No Matches
test_malloc_dbg.c File Reference

File used to test the malloc_dbg, calloc_dbg and free_dbg functions. More...

#include <stdio.h>
#include <stdlib.h>
#include "malloc_dbg.h"
Include dependency graph for test_malloc_dbg.c:

Functions

int main (int argc, char *argv[])
 For IO operations if needed.
 

Detailed Description

File used to test the malloc_dbg, calloc_dbg and free_dbg functions.

This file only have a main function that calls malloc, calloc and free. When the program exits, memory leaks must be printed.

Author
tinouduart33
See also
malloc_dbg.c, malloc_dbg.h

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

For IO operations if needed.

For the EXIT_SUCCESS macro and the "real" malloc, calloc and free functions. For the macros malloc, calloc and free and the malloc_dbg, calloc_dbg and free_dbg functions.

Main function

Parameters
argcnumber of arguments (not used)
argvlist of arguments (not used)
Returns
0 on exit
23{
24 int* iptr = malloc(10 * sizeof(int));
25 char* cptr = calloc(256, sizeof(char));
26
27 free(iptr);
28 // free(cptr);
29
30 return 0;
31}
#define malloc(bytes)
This macro replace the standard malloc function with malloc_dbg.
Definition malloc_dbg.h:18
#define free(ptr)
This macro replace the standard free function with free_dbg.
Definition malloc_dbg.h:26
#define calloc(elemCount, elemSize)
This macro replace the standard calloc function with calloc_dbg.
Definition malloc_dbg.h:22