-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathallocTracker.h
More file actions
48 lines (36 loc) · 863 Bytes
/
allocTracker.h
File metadata and controls
48 lines (36 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// Created by Congyu Luo on 4/27/23.
//
#ifndef TEST_ALLOCTRACKER_H
#define TEST_ALLOCTRACKER_H
// Standard LL for tracking allocations
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
#include <stdbool.h>
typedef struct allocNode {
void *ptr;
size_t size;
bool isFreed;
int id;
struct allocNode *next;
} allocNode;
typedef struct allocList {
allocNode *head;
int size;
} allocList;
void addNode(allocNode *node);
allocNode* findAllocNode(void *ptr);
int freeAlloc(void *ptr);
void* addAlloc(void *ptr, size_t size);
// Dereference search functions
bool inRange(allocNode *node, void* ptr);
allocNode* getAllocatedNode(void* ptr);
void exportAllocList();
void deleteList();
// Print function
void printAllocList();
void printAllAllocList();
// Test func
allocNode* getAllocHead();
#endif //TEST_ALLOCTRACKER_H