Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to dynamically cascade double linked lists
    primarykey
    data
    text
    <p>I'm creating double linked lists and each entry of the list could have another list inside.</p> <p>The struct:</p> <pre><code>struct symTabEntry { char *name; symTabEntry *scope; symTabEntry *head; symTabEntry *vader; symTabEntry *next; symTabEntry *prev; }; </code></pre> <p>Pointers to specific elements:</p> <pre><code>symTabEntry **currentHead; //Points to the head of the current scope symTabEntry **currentVader; //Points to the vader head element of the current scope </code></pre> <p>Since I'm working with the utlist.h library I always have to provide the pointer the the head element of the list I'm currently working on to add entries or iterate over all entries.</p> <p>The problem is when I'm adding a entry I want to switch to the scope of the current entry and add the next entries inside the new scope and later try to output the vader of subscope elements, I'm getting a segmentation fault. The vader element provided as parameter is the latest added entry and new entries are always added to the currentHead.</p> <p>Function to switch scope:</p> <pre><code>void newFunctionScope(symTabEntry *vader) { currentVader = &amp;vader; currentHead = &amp;vader-&gt;scope; } </code></pre> <p>Error occurs when accessing foundEntry->vader:</p> <pre><code>void printSymboltable(symTabEntry *entry) { symTabEntry *foundEntry; DL_FOREACH(entry, foundEntry) { printf("%s\t%d\t%d\t%d\t%s\t%s", foundEntry-&gt;name, foundEntry-&gt;line, foundEntry-&gt;offset, foundEntry-&gt;parameter, types[foundEntry-&gt;type], types[foundEntry-&gt;internType]); if(foundEntry-&gt;vader != NULL) { printf("\t%s\n", foundEntry-&gt;vader-&gt;name); } else { printf("\n"); } if(foundEntry-&gt;scope != NULL) { printSymboltable(foundEntry-&gt;scope); } } } </code></pre> <p>Complete source code: <a href="http://pastebin.com/nNp98i3e" rel="nofollow">http://pastebin.com/nNp98i3e</a></p> <p>Or any other suggestions?</p> <p>Thanks for help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload