lib<fancy_memory> 0.1.0
A very simple, very experimental C library for tracking dynamically allocated memory
Loading...
Searching...
No Matches
fancy_memory.h
Go to the documentation of this file.
1/*
2 Copyright (c) 2023 BB-301 <fw3dg3@gmail.com>
3
4 Permission is hereby granted, free of charge, to any person
5 obtaining a copy of this software and associated documentation
6 files (the “Software”), to deal in the Software without restriction,
7 including without limitation the rights to use, copy, modify, merge,
8 publish, distribute, sublicense, and/or sell copies of the Software,
9 and to permit persons to whom the Software is furnished to do so,
10 subject to the following conditions:
11
12 The above copyright notice and this permission notice shall be included
13 in all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 THE SOFTWARE.
22*/
23
28#ifndef __FANCY_MEMORY_H__
29#define __FANCY_MEMORY_H__
30
31#include <stdio.h>
32#include <stdlib.h>
33#include <stdint.h>
34
48typedef struct fancy_memory_s fancy_memory_t;
49
60
68
81
94void *fancy_memory_malloc(fancy_memory_t *self, size_t size);
95
109void fancy_memory_free(fancy_memory_t *self, void *pointer);
110
129void *fancy_memory_realloc(fancy_memory_t *self, void *pointer, size_t size);
130
139void fancy_memory_debug(fancy_memory_t const *self, FILE *stream);
140
151
159#endif
fancy_memory_t * fancy_memory_create(void)
The factory method that needs to be used in order to instantiate a fancy_memory_t object.
void fancy_memory_free(fancy_memory_t *self, void *pointer)
The method that must be used to free (and stop tracking) memory previously allocated using the same f...
void fancy_memory_debug(fancy_memory_t const *self, FILE *stream)
A method that can be used to print (i.e., write) a summary of the tracked memory for self .
void * fancy_memory_malloc(fancy_memory_t *self, size_t size)
The method that must be used to allocate and track new memory.
struct fancy_memory_s fancy_memory_t
An opaque data type that is used as a container for storing "memory tracking" related data,...
Definition: fancy_memory.h:48
void fancy_memory_get_library_version(uint16_t *major, uint16_t *minor, uint16_t *revision)
A method that can be used to retrieve the library's current version. It works by populating the argum...
void * fancy_memory_realloc(fancy_memory_t *self, void *pointer, size_t size)
The method that must be used to reallocate (and update the tracking information of) memory that was i...
void fancy_memory_destroy(fancy_memory_t *self)
The method that should be used to destroy a fancy_memory_t object once that object is no longer neede...
size_t fancy_memory_get_total(fancy_memory_t const *self)
The method that must be used to retrieve the total amount of memory (in bytes) currently being tracke...