<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: a tutorial on &#8216;dynamic&#8217; arrays in C</title>
	<atom:link href="http://fydo.net/gamedev/dynamic-arrays/feed" rel="self" type="application/rss+xml" />
	<link>http://fydo.net/gamedev/dynamic-arrays</link>
	<description>On the Internet, nobody knows you&#039;re a cat.</description>
	<lastBuildDate>Fri, 24 Jun 2011 22:41:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: tavaris</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-56561</link>
		<dc:creator>tavaris</dc:creator>
		<pubDate>Tue, 17 May 2011 21:30:31 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-56561</guid>
		<description>Lets say you have to dynamically allocate an array of structs and you have to read a number in from an input file that tells you how big the array is going to be. How would you do that?</description>
		<content:encoded><![CDATA[<p>Lets say you have to dynamically allocate an array of structs and you have to read a number in from an input file that tells you how big the array is going to be. How would you do that?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erik</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-56163</link>
		<dc:creator>Erik</dc:creator>
		<pubDate>Thu, 12 May 2011 18:21:01 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-56163</guid>
		<description>@ulrich: While you&#039;re right in that the pointer address might change as a new region in memory is allocated, realloc guarantees that the data is moved properly and the old memory freed. Thus, you don&#039;t need to copy the data yourself (it is an error to do this: you&#039;re accessing memory that has been free&#039;d by realloc()).</description>
		<content:encoded><![CDATA[<p>@ulrich: While you&#8217;re right in that the pointer address might change as a new region in memory is allocated, realloc guarantees that the data is moved properly and the old memory freed. Thus, you don&#8217;t need to copy the data yourself (it is an error to do this: you&#8217;re accessing memory that has been free&#8217;d by realloc()).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fydo</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-51302</link>
		<dc:creator>fydo</dc:creator>
		<pubDate>Wed, 16 Mar 2011 15:57:31 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-51302</guid>
		<description>Frank,

I&#039;m not getting any of those errors when compiling the code example using GCC 4.4.3. What compiler are you using?</description>
		<content:encoded><![CDATA[<p>Frank,</p>
<p>I&#8217;m not getting any of those errors when compiling the code example using GCC 4.4.3. What compiler are you using?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-51278</link>
		<dc:creator>Frank</dc:creator>
		<pubDate>Wed, 16 Mar 2011 13:22:15 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-51278</guid>
		<description>This code is giving a bunch of warnings and errors when trying to compile it:

test.c:4: warning: parameter names (without types) in function declaration
test.c: In function ‘addToArray’:
test.c:40: error: ‘num_elements’ undeclared (first use in this function)
test.c:40: error: (Each undeclared identifier is reported only once
test.c:40: error: for each function it appears in.)
test.c:40: error: ‘num_allocated’ undeclared (first use in this function)
test.c:48: error: ‘the_array’ undeclared (first use in this function)

The errors seem obvious, but I&#039;m wondering how you&#039;re using the function to avoid them? Seriously, when you make a tutorial like this, it would be a good idea to include an actual working example of implementing it.</description>
		<content:encoded><![CDATA[<p>This code is giving a bunch of warnings and errors when trying to compile it:</p>
<p>test.c:4: warning: parameter names (without types) in function declaration<br />
test.c: In function ‘addToArray’:<br />
test.c:40: error: ‘num_elements’ undeclared (first use in this function)<br />
test.c:40: error: (Each undeclared identifier is reported only once<br />
test.c:40: error: for each function it appears in.)<br />
test.c:40: error: ‘num_allocated’ undeclared (first use in this function)<br />
test.c:48: error: ‘the_array’ undeclared (first use in this function)</p>
<p>The errors seem obvious, but I&#8217;m wondering how you&#8217;re using the function to avoid them? Seriously, when you make a tutorial like this, it would be a good idea to include an actual working example of implementing it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Broadhurst</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-37560</link>
		<dc:creator>Martin Broadhurst</dc:creator>
		<pubDate>Mon, 18 Oct 2010 15:48:03 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-37560</guid>
		<description>I should add that the main disadvantage of dynamic arrays is that each time you reallocate, the contents of the buffer need to be copied. If your array starts off small and gets very large, this copying can really impact on performace.
One solution is to have a dynamic array of arrays, and store the elements in the arrays. When you run out of space, you just add another array. You can have the size of each array larger than the previous one, so that you still double the capacity at each allocation, but no copying is involved.
I have written an implementation of this strucure here:
http://www.martinbroadhurst.com/articles/list-as-a-dynamic-array-of-increasing-sized-arrays.html</description>
		<content:encoded><![CDATA[<p>I should add that the main disadvantage of dynamic arrays is that each time you reallocate, the contents of the buffer need to be copied. If your array starts off small and gets very large, this copying can really impact on performace.<br />
One solution is to have a dynamic array of arrays, and store the elements in the arrays. When you run out of space, you just add another array. You can have the size of each array larger than the previous one, so that you still double the capacity at each allocation, but no copying is involved.<br />
I have written an implementation of this strucure here:<br />
<a href="http://www.martinbroadhurst.com/articles/list-as-a-dynamic-array-of-increasing-sized-arrays.html" rel="nofollow">http://www.martinbroadhurst.com/articles/list-as-a-dynamic-array-of-increasing-sized-arrays.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin Broadhurst</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-37341</link>
		<dc:creator>Martin Broadhurst</dc:creator>
		<pubDate>Wed, 13 Oct 2010 08:23:06 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-37341</guid>
		<description>Good work!
If you want to be able to use more than one dynamic array in a program, it&#039;s a good idea to turn the array into a struct type.
You can store elements of any type if you make the array an array of void pointers.
I&#039;ve written an implementation which you can find here:
http://www.martinbroadhurst.com/articles/dynamic-array.html</description>
		<content:encoded><![CDATA[<p>Good work!<br />
If you want to be able to use more than one dynamic array in a program, it&#8217;s a good idea to turn the array into a struct type.<br />
You can store elements of any type if you make the array an array of void pointers.<br />
I&#8217;ve written an implementation which you can find here:<br />
<a href="http://www.martinbroadhurst.com/articles/dynamic-array.html" rel="nofollow">http://www.martinbroadhurst.com/articles/dynamic-array.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: glicholas</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-36317</link>
		<dc:creator>glicholas</dc:creator>
		<pubDate>Tue, 14 Sep 2010 18:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-36317</guid>
		<description>By using this example I was able to implement an array made of doubles to represent x and y coordinates.  I was able to read in an unknown amount and take all data.  It worked for thousands and thousands of members.  This is the most clear and precise example I was able to find anywhere on the net. Thanks a bunch!</description>
		<content:encoded><![CDATA[<p>By using this example I was able to implement an array made of doubles to represent x and y coordinates.  I was able to read in an unknown amount and take all data.  It worked for thousands and thousands of members.  This is the most clear and precise example I was able to find anywhere on the net. Thanks a bunch!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nilesh</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-34920</link>
		<dc:creator>Nilesh</dc:creator>
		<pubDate>Sat, 31 Jul 2010 15:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-34920</guid>
		<description>Man thanks a million!
I was struggling with dynamic structure array since last three days!
This tutorial has helped me like anything.
Thanks Thanks Thanks Thanks.</description>
		<content:encoded><![CDATA[<p>Man thanks a million!<br />
I was struggling with dynamic structure array since last three days!<br />
This tutorial has helped me like anything.<br />
Thanks Thanks Thanks Thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sandeep</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-34391</link>
		<dc:creator>Sandeep</dc:creator>
		<pubDate>Fri, 09 Jul 2010 22:33:43 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-34391</guid>
		<description>thanks for posting this. saved me some time.</description>
		<content:encoded><![CDATA[<p>thanks for posting this. saved me some time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Simon</title>
		<link>http://fydo.net/gamedev/dynamic-arrays/comment-page-1#comment-31442</link>
		<dc:creator>Simon</dc:creator>
		<pubDate>Wed, 07 Apr 2010 14:22:56 +0000</pubDate>
		<guid isPermaLink="false">http://fydo.net/misc/dynamic-arrays#comment-31442</guid>
		<description>Do you think there is any way to resize (downsize) the array?

I would like to create an array where data is added dynamically and when the element has been treated by the program the memory is freed.

I am programming in C# and I cannot use any of the C++ STD lib.</description>
		<content:encoded><![CDATA[<p>Do you think there is any way to resize (downsize) the array?</p>
<p>I would like to create an array where data is added dynamically and when the element has been treated by the program the memory is freed.</p>
<p>I am programming in C# and I cannot use any of the C++ STD lib.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

