Skip to content

A simple wrapper around malloc function to debug code. it's for learning C Macros and Makefiles

Notifications You must be signed in to change notification settings

hamedgk/dbg-malloc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

#include <stdio.h>
#include "dbgalloc.h"


void callback(struct alloc_reggetster_t *reg){
    printf("callback gets called and prints filename: %s\n", reg->file_name);
}


int main(){
    INIT_ALLOC_REGS();
        


    int *a = (int*)DBGALLOC(sizeof(int)); //oh forgot to deallocate!
        

    //DBGFREE(a);


    INVOKE_CALLBACK(callback); //invokes a callback function on unfreed pointers
    NOT_FREED(); //outputs unfreed pointers
    return 0;
}

Output

callback gets called and prints filename: main.c
NOT FREED 0x55cc0df942a0 at main.c:15

Install

to build the library:

make

to install:

sudo make install

About

A simple wrapper around malloc function to debug code. it's for learning C Macros and Makefiles

Resources

Stars

Watchers

Forks