/
/
/
util.h
Amendments on February 15, 2024
The previous malloc note stuff was removed since it required every
xmalloc call to include a string, which was laborious to use and
added a lot of code and memory space having to store all those
strings.
Now when MALLOC_DEBUG is defined, the stack is walked to find the
symbols of each function along the way to xmalloc and pointers to
elements of the symbol table are stored, minimizing the amount of
strings that need to be stored in memory, and providing a way to see
the full stack trace of each allocation with xalloc_print. We can
also check in xfree that the allocation was still in our list to
avoid a double free or a junk free.
jcs made amendment
587
about 1 month ago
Amendments on February 1, 2024
jcs made amendment
583
about 1 month ago
Amendments on November 14, 2023
jcs made amendment
538
4 months ago
Amendments on March 27, 2023
jcs made amendment
454
about 1 year ago
Amendments on March 2, 2023
This will return false if the xrealloc failed, leaving the original
pointer untouched. With the macro, the pointer would get overwritten
with NULL and not be able to be freed.
jcs made amendment
332
about 1 year ago
Amendments on March 1, 2023
Display a warning, but return NULL
Also remove MALLOC_DEBUG, it is not as helpful as I wanted and just
bloats things having to store all these note strings
jcs made amendment
331
about 1 year ago
Amendments on February 5, 2023
Mostly unused variables
jcs made amendment
300
about 1 year ago
Amendments on November 11, 2022
jcs made amendment
278
about 1 year ago
Amendments on September 8, 2022
jcs made amendment
246
about 1 year ago
Amendments on August 3, 2022
jcs made amendment
227
about 1 year ago
Amendments on July 31, 2022
If THINK C supported __func__ this would be much easier, but for now
we have to manually annotate every allocation. This will help find
the source of memory leaks.
jcs made amendment
224
about 1 year ago
Amendments on July 21, 2022
Instead of free(ptr), use xfree(&ptr) and after it calls
DisposePtr(ptr), it will update ptr to point at NULL to catch
use-after-frees.
When MALLOC_DEBUG is defined, each allocation is added to a
list, and removed when freed. If it's not in the list at free
time, it's a double-free. Also, instead of pointing pointers at
NULL, point them to a pre-defined block of zeroes and in the
idle loop, periodically check that this block is still zero. This
will also catch use-after-frees in a more reliable (but costly)
way.
jcs made amendment
220
about 1 year ago
Amendments on July 12, 2022
jcs made amendment
199
about 1 year ago
Amendments on June 30, 2022
jcs made amendment
177
about 1 year ago
Amendments on June 22, 2022
This should be easy but doing so from signed chars causes problems,
so casting to unsigned char is needed, but then each needs to be cast
to a long before shifting.
jcs made amendment
161
about 1 year ago
Amendments on June 21, 2022
This will trigger after the configured number of idle seconds, when
there are no active sessions. A mouse click or key press will unblank
right away, otherwise it will unblank automatically after the
configured number of runtime seconds.
This is a more CPU-friendly alternative to a normal screen saver, and
it will only run for a short amount of time to do its job of blanking
the screen to prevent burn-in.
jcs made amendment
159
about 1 year ago
Amendments on June 1, 2022
calloc does what this did, who knew?
Avoid dynamic allocation in vwarn() so errors about OOM conditions
can succeed
jcs made amendment
112
about 1 year ago
Amendments on May 15, 2022
Remove unused variables and fix some returns
Found by compiling with Clang
jcs made amendment
101
about 1 year ago
Amendments on March 29, 2022
jcs made amendment
89
about 1 year ago
Amendments on February 10, 2022
jcs made amendment
70
over 2 years ago