pointers - Design choices implementing linked list in C -


i hope question isn't open format of site. new c, , enjoy playing around learn intricacies. current "task" building singly-linked list.

here's setup: first iteration of linked list program stored nodes in 1 contiguous block of memory. required realloc push , pop functions.

however, when got using realloc, decided try new design malloc , free called during creation or deletion of single node, respectively. i've read on larger scales can hampering program.

which way better, first or second? or both ideas lend implementations? forgive me if broad, want check understanding , learn designing program.

your second way 'classic' linked list. malloc each node in turn. each node has pointer next node. last 1 has null next pointer. have root pointer points first node

there no scale issue this; modern heap managers efficient. there brain scale issue. need write nice clean code dont leak or crash :-)

if doing on linux learn how use tool called valgrind. (and of course learn how use gdb)


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -