Skip to content

x3hy/node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

node3.h | linked-list allocator
-------------------------------
C has no built in garbage collector, this means if you forget to manually free allocated memory, it will persist and eventually fill the ram overtime. This is bad. To negate this issue you could use a garbage collector which is used to automatically check for unfreed memory which is then deallocated safely.

This library can be used to group memory usage into a unform structure, this allows for quick deallocation of all memory and a few more nice features that are not included in stdlib.h (such as information on memory usage).


-------------------------------
What does node3.h provide:
-------------------------------
node_strdup, nfree, nalloc, nrealloc all work the same as strdup, free, malloc and realloc. node_alloc_total returns the total amount of user-allocated memory, if the user allocates 4 bytes here and 10 bytes there, this function would return 14. node_mem_total returns the total amount of ram usage, this includes the prior 14 plus the size of each node struct in the linked list.

- node3.h is a tiny library, under 200 lines of code (191).
- This library will increase the memory saftey of projects.
- Zero non-standard dependancies (only dep is stdlib for memory functions)


-------------------------------
What are the downsides?
-------------------------------
- As mentioned, each node in the linked-list does add some memory usage to the programs runtime, this is very minimal but will be noticable in minisicule projects.
- You are required to juggle a few extra variables such as the allocation pool/group.


-------------------------------
Documentation
-------------------------------
Read the node.c file, it contains examples of all the given functions. Read into the node3.h file for more information, this library is tiny and mainly contains basic recreations of standard functions, this does not require any documentation

About

A minimal linked-list memory handler.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages