Quote Originally Posted by awsdert View Post
No it doesn't fully work, I had tracked the overwrite down to a situation where realloc had returned a valid pointer but never actually acquired the needed memory, leaving my code to believe it succeeded and carry on as though it had done so, where I had check the return code
The likelihood of that is very, very small. realloc() is a very old function, and is very much in use. I would hazard a guess that the reason it now works is that under the covers mmap() allocates memory in full pages.

I'ld find the error and fix it for you if your GitHub repo actually built:

Code:
hamster@hamster-envy:~$ git clone GitHub - awsdert/alu: Library modeled after the Arithmetic Logic Unit built into CPUs
Cloning into 'alu'...
remote: Enumerating objects: 71, done.
remote: Counting objects: 100% (71/71), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 537 (delta 38), reused 33 (delta 0), pack-reused 466
Receiving objects: 100% (537/537), 178.78 KiB | 407.00 KiB/s, done.
Resolving deltas: 100% (367/367), done.
hamster@hamster-envy:~$ cd alu
hamster@hamster-envy:~/alu$ make build
#MAKECMDGOALS=build
cd mak && make -j 1 --no-print-directory -f main.mak build
PRJ_LIB_NAME=alu


Cloning into 'unic'...
remote: Enumerating objects: 198, done.
remote: Counting objects: 100% (198/198), done.
remote: Compressing objects: 100% (161/161), done.
remote: Total 198 (delta 107), reused 115 (delta 26), pack-reused 0
Receiving objects: 100% (198/198), 61.33 KiB | 286.00 KiB/s, done.
Resolving deltas: 100% (107/107), done.


Checking 3rd Party libraries are upto date
cd '../cloned/unic' && git fetch && git pull
Finished checking
PRJ_DST_BIN=test_alu.AppImage
PRJ_DST_LIB=libalu.so
mkdir ../bin
mkdir ../lib
cc -D NDEBUG -O3  -fPIC -Wall -Wextra -pedantic -I ../cloned/unic/include -I ../include -D UNIC_FALLBACK  -o ../src/alu_vec.o -c ../src/alu_vec.c
In file included from /usr/include/stdio.h:41:0,
                 from ../include/alu.h:11,
                 from ../src/alu_vec.c:1:
/usr/include/x86_64-linux-gnu/bits/libio.h:466:58: error: expected declaration specifiers or ‘...’ before ‘)’ token
 extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t);
                                                          ^
main.mak:147: recipe for target '../src/alu_vec.o' failed
make[1]: *** [../src/alu_vec.o] Error 1
makefile:9: recipe for target 'build' failed
make: *** [build] Error 2
Even when I try to hotwire the build process, things are not right, especially in tests/test_alu.c:

Code:
hamster@hamster-envy:~/alu/src$ gcc -o alu *.c ../tests/test_alu.c -I ../include -I ../cloned/unic/include/
../tests/test_alu.c: In function ‘rng’:
../tests/test_alu.c:232:6: warning: implicit declaration of function ‘ror’ [-Wimplicit-function-declaration]
  n = ror( n, X % bitsof(size_t) );
      ^~~
../tests/test_alu.c: In function ‘func_wrChar32’:
../tests/test_alu.c:519:7: warning: assignment makes integer from pointer without a cast [-Wint-conversion]
   ret = alu_block_expand( dst, dst->taken + 50 );
       ^
../tests/test_alu.c: In function ‘reg_print_value’:
../tests/test_alu.c:556:35: warning: passing argument 2 of ‘alu_get_reg_node’ makes integer from pointer without a cast [-Wint-conversion]
  int ret = alu_get_reg_node( alu, &tmp, 0 );
                                   ^
In file included from ../tests/test_alu.c:1:0:
../include/alu.h:346:8: note: expected ‘size_t {aka long unsigned int}’ but argument is of type ‘uint_t * {aka unsigned int *}’
 uint_t alu_get_reg_node( alu_t *alu, size_t need );
        ^~~~~~~~~~~~~~~~
../tests/test_alu.c:556:12: error: too many arguments to function ‘alu_get_reg_node’
  int ret = alu_get_reg_node( alu, &tmp, 0 );
....