vincenzopalazzo / cpstl

Copy and Paste standard library (CPSTL) is a repository with a collection of data structure and algorithms in many different languages
https://docs.page/vincenzopalazzo/cpstl
GNU General Public License v2.0
14 stars 3 forks source link

cpp: introducing basic trie implementation #43

Open vincenzopalazzo opened 2 years ago

vincenzopalazzo commented 2 years ago

This required more work, but provide an example of API that I want to expose with the data structure

Fixes https://github.com/vincenzopalazzo/cpstl/issues/23 Fixes https://github.com/vincenzopalazzo/cpstl/issues/18

Signed-off-by: Vincenzo Palazzo vincenzopalazzodev@gmail.com

vincenzopalazzo commented 2 years ago

Debugging stack trace

➜  build git:(cpp/trie) ✗ valgrind -s --track-origins=yes --leak-check=full ./Trie                                                             
==180522== Memcheck, a memory error detector
==180522== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==180522== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==180522== Command: ./Trie
==180522== 
==180522== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==180522== 
==180522== Process terminating with default action of signal 11 (SIGSEGV)
==180522==  Access not within mapped region at address 0x1FFE801FF8
==180522== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==180522==    at 0x10ACB9: cpstl::internal::Node<char>::Node(cpstl::ALPHABETH, bool) (in /home/vincent/Github/cpstl/cpp/data_structures/trie/build/Trie)
==180522==  If you believe this happened as a result of a stack
==180522==  overflow in your program's main thread (unlikely but
==180522==  possible), you can try to increase the size of the
==180522==  main thread stack using the --main-stacksize= flag.
==180522==  The main thread stack size used in this run was 8388608.
==180522== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==180522== 
==180522== Process terminating with default action of signal 11 (SIGSEGV)
==180522==  Access not within mapped region at address 0x1FFE801FF0
==180522== Stack overflow in thread #1: can't grow stack to 0x1ffe801000
==180522==    at 0x4831134: _vgnU_freeres (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_core-amd64-linux.so)
==180522==  If you believe this happened as a result of a stack
==180522==  overflow in your program's main thread (unlikely but
==180522==  possible), you can try to increase the size of the
==180522==  main thread stack using the --main-stacksize= flag.
==180522==  The main thread stack size used in this run was 8388608.
==180522== 
==180522== HEAP SUMMARY:
==180522==     in use at exit: 72,704 bytes in 1 blocks
==180522==   total heap usage: 1 allocs, 0 frees, 72,704 bytes allocated
==180522== 
==180522== LEAK SUMMARY:
==180522==    definitely lost: 0 bytes in 0 blocks
==180522==    indirectly lost: 0 bytes in 0 blocks
==180522==      possibly lost: 0 bytes in 0 blocks
==180522==    still reachable: 72,704 bytes in 1 blocks
==180522==         suppressed: 0 bytes in 0 blocks
==180522== Reachable blocks (those to which a pointer was found) are not shown.
==180522== To see them, rerun with: --leak-check=full --show-leak-kinds=all
==180522== 
==180522== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
[1]    180522 segmentation fault (core dumped)  valgrind -s --track-origins=yes --leak-check=full ./Trie