Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In a doubly circular linked list, we can resolve the corrupted pointer, if any one of the pointer(previous or next pointer) is corrupted.</p> <p>If next pointer is not proper, we can traverse the list reversely and then we can correct it, Or else if previous pointer is not proper, we can traverse the list forwardly to correct it.</p> <p>Now we have to think how to identify a corrupted link(pointer) in a list. We use to allocate dynamic memory(<code>malloc</code> or <code>calloc</code>) for each nodes separately. If we call <code>malloc</code> or <code>calloc</code> frequently for small small memory may affects to performance of the system. Rather than this we can allocate a big junk of heap memory at initial stage and then we can implement our own memory allocation function for each node creation. And also use this only for list node creation to identify corrupted links of the list.</p> <p>This increases the performance of the system and also it will help to indentify whether the link of a node is corrupted or not, by checking the limits of the initial memory allocated for the list.</p> <p>Once we get a pointer to a node, we have to do the below checks first before accessing the data in that node.</p> <pre><code>check_limit(node); check_limit(node-&gt;next); check_limit(node-&gt;previous); </code></pre> <p>And also we can check whether the <code>node-&gt;previous</code> is equal to <code>current_node</code>. </p> <p>After this also there may be possibility of <code>node-&gt;next</code> might be pointing to wrong address but inside the initial memory limit. In this case we can read <code>node-&gt;next-&gt;previous</code> (this will not leads to crash, even if <code>next</code> is pointing wrong address but inside the initial memory limit) and check whether it is equal to <code>node</code> or not.</p> <p>And also unused intial memory space should be <code>NULL</code> setted always (using <code>memset</code>). </p> <p>By these ways we can find out the 99% of the corrupted pointers in a list. </p>
 

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