<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'Linked List issue / debugging' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'Linked List issue / debugging' posted on the 'C and C++' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 25 May 2013 05:27:53 -0700</pubDate>
    <lastBuildDate>Sat, 25 May 2013 05:27:53 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>Linked List issue / debugging</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423798/423798/linked-list-issue--debugging/</link>
      <description>I have been struggling with this problem for about 2 days now and I just cant figure out what the problem is.&lt;br /&gt;
I am making a linked list that points to a char array at different addresses.&lt;br /&gt;
So for the 8byte linked list, it points to an address every 8 bytes.&lt;br /&gt;
link lists 32bytes, 64bytes etc also follow the same pattern.&lt;br /&gt;
Here is the code that is giving me issues:&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
void CMemoryPoolManager::initializeLinkedList(char MM_pool[], int chunks, int chunkSize, int offset)
  {
	MemoryBlock current;
	MemoryBlock *pCurrent = NULL;
        pCurrent = &amp;amp;current;
	for (int i=0; i &amp;lt; chunks; i++)
	{
		pCurrent = (MemoryBlock *)&amp;amp;MM_pool[sizeof(CMemoryPoolManager) +1 + (i * chunkSize) + offset];
		pCurrent-&amp;gt;pNext = NULL;
		pCurrent-&amp;gt;pPrevious = NULL;
		pCurrent-&amp;gt;bInUse = false;

		switch (chunkSize)
		{
		case 8:
			pCurrent-&amp;gt;pNext = p8Byte;
			if (p8Byte != NULL)
				p8Byte-&amp;gt;pPrevious = pCurrent;
			p8Byte = pCurrent;
			break;
		case 32:
			pCurrent-&amp;gt;siSize = 32;
			pCurrent-&amp;gt;pNext = p32Byte;
			if (p32Byte != NULL)
				p32Byte-&amp;gt;pPrevious = pCurrent;
			p32Byte = pCurrent;
			break;
		case 64:
			pCurrent-&amp;gt;siSize = 64;
			pCurrent-&amp;gt;pNext = p64Byte;
			if (p64Byte != NULL)
				p64Byte-&amp;gt;pPrevious = pCurrent;
			p64Byte = pCurrent;
			break;

		}
	}
}
&lt;/pre&gt;&lt;br /&gt;
MemoryBlock is a struct in CMemoryPoolManager that holds the pointers next and previous&lt;br /&gt;
size is just for testing disregard that.&lt;br /&gt;
and the p##Byte are the linked lists inside CMemoryPoolManager&lt;br /&gt;
the line: &lt;br /&gt;
&lt;pre class="sourcecode"&gt;
pCurrent = (MemoryBlock *)&amp;amp;MM_pool[sizeof(CMemoryPoolManager) +1 + (i * chunkSize) + offset];
&lt;/pre&gt;&lt;br /&gt;
gets the position of where to create the next "node".&lt;br /&gt;
&lt;br /&gt;
Now on to the question / problem.&lt;br /&gt;
When creating the 8byte list,it doesnt link properly.&lt;br /&gt;
When it hits the "case 8:" line pCurrent-&amp;gt;pNext changes by itself and subsequently changes the p8Byte links. So it never creates a proper list.&lt;br /&gt;
What really makes things weird is that the 32 and 64 byte lists are made correctly with no issues. Its the same code, it follows the same pattern, but the 8Byte list just doesnt work for whatever reason!&lt;br /&gt;
I have no clue as to why...ive tried a variety of things and nothing seems to help.&lt;br /&gt;
Can anyone suggest anything to try or see what the issue might be?&lt;br /&gt;
Any help at all would be GREATLY appreciated!!&lt;br /&gt;
Thanks!&lt;br /&gt;
&lt;br /&gt;
=Ghost=&amp;gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423798/423798/linked-list-issue--debugging/</guid>
      <pubDate>Sat, 14 May 2011 10:49:23 -0700</pubDate>
      <category>C and C++</category>
    </item>
    <item>
      <title>Re: Linked List issue / debugging</title>
      <link>http://www.programmersheaven.com/mb/CandCPP/423798/423810/re-linked-list-issue--debugging/#423810</link>
      <description>&lt;span style="color: Blue;"&gt;Looking very closely you can see that 'case 8' is missing one line (compare it with other cases) - something about the size...&lt;/span&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/CandCPP/423798/423810/re-linked-list-issue--debugging/#423810</guid>
      <pubDate>Sun, 15 May 2011 04:33:03 -0700</pubDate>
      <category>C and C++</category>
    </item>
  </channel>
</rss>