<?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: Memory Allocation for the budding Objective-C programmer</title>
	<atom:link href="http://www.bit-101.com/blog/?feed=rss2&#038;p=2253" rel="self" type="application/rss+xml" />
	<link>http://www.bit-101.com/blog/?p=2253</link>
	<description>Bill Gates Touched My Mac Book Pro</description>
	<lastBuildDate>Thu, 09 Sep 2010 17:38:28 -0700</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: SSI</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11737</link>
		<dc:creator>SSI</dc:creator>
		<pubDate>Wed, 05 Aug 2009 09:14:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11737</guid>
		<description>OR how to write at desired memory location(address) in C/C++?</description>
		<content:encoded><![CDATA[<p>OR how to write at desired memory location(address) in C/C++?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SSI</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11736</link>
		<dc:creator>SSI</dc:creator>
		<pubDate>Wed, 05 Aug 2009 09:11:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11736</guid>
		<description>Can any body tell me how to allocate a chunk of memory at desired memory address using malloc or any other function in C/C++?</description>
		<content:encoded><![CDATA[<p>Can any body tell me how to allocate a chunk of memory at desired memory address using malloc or any other function in C/C++?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kp</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11735</link>
		<dc:creator>kp</dc:creator>
		<pubDate>Mon, 20 Jul 2009 00:02:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11735</guid>
		<description>oops. Right you are. My bad. Fixed now. That&#039;s what happens when you copy and paste code. :)</description>
		<content:encoded><![CDATA[<p>oops. Right you are. My bad. Fixed now. That&#8217;s what happens when you copy and paste code. <img src='http://www.bit-101.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: umm...</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11734</link>
		<dc:creator>umm...</dc:creator>
		<pubDate>Sun, 19 Jul 2009 22:29:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11734</guid>
		<description>To clarify on what Markus said, look at your post again...

It uses int *myInts = malloc(sizeof(CGPoint) * 50);

I&#039;m guaranteed that&#039;s a mistake.</description>
		<content:encoded><![CDATA[<p>To clarify on what Markus said, look at your post again&#8230;</p>
<p>It uses int *myInts = malloc(sizeof(CGPoint) * 50);</p>
<p>I&#8217;m guaranteed that&#8217;s a mistake.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kp</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11733</link>
		<dc:creator>kp</dc:creator>
		<pubDate>Thu, 16 Jul 2009 23:21:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11733</guid>
		<description>Markus, array notation is magical. It knows how many bytes are in each element. You made your array as a pointer to int: int *myPoints

If you make it a pointer to CGPoint, you&#039;ll be all set: CGPoint *myPoints.</description>
		<content:encoded><![CDATA[<p>Markus, array notation is magical. It knows how many bytes are in each element. You made your array as a pointer to int: int *myPoints</p>
<p>If you make it a pointer to CGPoint, you&#8217;ll be all set: CGPoint *myPoints.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Markus</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11732</link>
		<dc:creator>Markus</dc:creator>
		<pubDate>Thu, 16 Jul 2009 22:34:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11732</guid>
		<description>&quot;int *myPoints = malloc(sizeof(CGPoint) * 50);&quot;

myPoints[0]= CGPointMake(100, 100);
myPoints[1]= CGPointMake(110, 110);
myPoints[2]= CGPointMake(120, 120);&quot;

wouldn&#039;t the [1] overwrite parts of the previous defined point? The compiler always increases the pointer by one byte using the brackets,
since it doesn&#039;t have any information about of the size of each object.

so the correct syntax should be:
&quot;
myPoints[0]= CGPointMake(100, 100);
myPoints[sizeof(CGPoint)]= CGPointMake(110, 110);
myPoints[sizeof(CGPoint)*2]= CGPointMake(120, 120);&quot;

or did I miss something?</description>
		<content:encoded><![CDATA[<p>&#8220;int *myPoints = malloc(sizeof(CGPoint) * 50);&#8221;</p>
<p>myPoints[0]= CGPointMake(100, 100);<br />
myPoints[1]= CGPointMake(110, 110);<br />
myPoints[2]= CGPointMake(120, 120);&#8221;</p>
<p>wouldn&#8217;t the [1] overwrite parts of the previous defined point? The compiler always increases the pointer by one byte using the brackets,<br />
since it doesn&#8217;t have any information about of the size of each object.</p>
<p>so the correct syntax should be:<br />
&#8221;<br />
myPoints[0]= CGPointMake(100, 100);<br />
myPoints[sizeof(CGPoint)]= CGPointMake(110, 110);<br />
myPoints[sizeof(CGPoint)*2]= CGPointMake(120, 120);&#8221;</p>
<p>or did I miss something?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kp</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11731</link>
		<dc:creator>kp</dc:creator>
		<pubDate>Sun, 12 Jul 2009 18:06:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11731</guid>
		<description>ok, well that is enticing.</description>
		<content:encoded><![CDATA[<p>ok, well that is enticing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jtgrassie</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11730</link>
		<dc:creator>jtgrassie</dc:creator>
		<pubDate>Sun, 12 Jul 2009 18:04:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11730</guid>
		<description>With a STL Vector certainly.
The elements are guaranteed to be stored in contiguous storage locations. Just grab the pointer to the first element and pass that to GL functions requiring c array.</description>
		<content:encoded><![CDATA[<p>With a STL Vector certainly.<br />
The elements are guaranteed to be stored in contiguous storage locations. Just grab the pointer to the first element and pass that to GL functions requiring c array.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kp</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11729</link>
		<dc:creator>kp</dc:creator>
		<pubDate>Sun, 12 Jul 2009 17:33:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11729</guid>
		<description>on the current project I&#039;m working on, I&#039;m heavily using primitive arrays as vector arrays for OpenGL drawing. I think this is a necessity because OpenGL takes pointers to various types of arrays directly. Could you use STL containers in that context, or would you need to convert them?</description>
		<content:encoded><![CDATA[<p>on the current project I&#8217;m working on, I&#8217;m heavily using primitive arrays as vector arrays for OpenGL drawing. I think this is a necessity because OpenGL takes pointers to various types of arrays directly. Could you use STL containers in that context, or would you need to convert them?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jtgrassie</title>
		<link>http://www.bit-101.com/blog/?p=2253#comment-11728</link>
		<dc:creator>jtgrassie</dc:creator>
		<pubDate>Sun, 12 Jul 2009 17:19:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.bit-101.com/blog/?p=2253#comment-11728</guid>
		<description>No offence taken Keith :)

The reason I highlight this is really because of one of the biggest strengths of Objective-C/C++, the fact you can mix C, C++ and Objective-C all together.
This allows you to use what&#039;s best / most appropriate language for given problem. I don&#039;t think there is any valid reason to disregard C++ usage in Objective-C, especially when it offers an elegant solution to a given problem.

For the specific problem you highlight - a mutable array of primitive types - an STL container really is the way to go.
If you really are going to bother describing malloc and free for a mutable array, you really should also describe realloc (which is what you are going to need to shrink and grow your array).
http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/</description>
		<content:encoded><![CDATA[<p>No offence taken Keith <img src='http://www.bit-101.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The reason I highlight this is really because of one of the biggest strengths of Objective-C/C++, the fact you can mix C, C++ and Objective-C all together.<br />
This allows you to use what&#8217;s best / most appropriate language for given problem. I don&#8217;t think there is any valid reason to disregard C++ usage in Objective-C, especially when it offers an elegant solution to a given problem.</p>
<p>For the specific problem you highlight &#8211; a mutable array of primitive types &#8211; an STL container really is the way to go.<br />
If you really are going to bother describing malloc and free for a mutable array, you really should also describe realloc (which is what you are going to need to shrink and grow your array).<br />
<a href="http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/" rel="nofollow">http://www.cplusplus.com/reference/clibrary/cstdlib/realloc/</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
