<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ayumusoft &#187; tech</title>
	<atom:link href="http://ayumusoft.com/category/tech/feed/" rel="self" type="application/rss+xml" />
	<link>http://ayumusoft.com</link>
	<description>Chimp Development; Smarter than Guerrilla Development</description>
	<lastBuildDate>Thu, 12 Nov 2009 19:37:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Strip you NSLog()s automatically</title>
		<link>http://ayumusoft.com/2009/11/303/</link>
		<comments>http://ayumusoft.com/2009/11/303/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 18:54:40 +0000</pubDate>
		<dc:creator>spike</dc:creator>
				<category><![CDATA[tech]]></category>

		<guid isPermaLink="false">http://ayumusoft.com/?p=303</guid>
		<description><![CDATA[The folks over at the iQuit blog have mentioned that disabling NSLog calls in your iPhone code results in a huge performance improvement.  Having done so myself, I can firmly attest to that.  An easy way to disable NSLog calls globally is to put a few lines of macros in your project&#8217;s precompiled header (.pch) [...]]]></description>
			<content:encoded><![CDATA[<p>The folks over at the iQuit blog have mentioned that <a href="http://blog.hawkey.org/?s=nslog">disabling NSLog calls in your iPhone code results in a huge performance improvement</a>.  Having done so myself, I can firmly attest to that.  An easy way to disable NSLog calls globally is to put a few lines of macros in your project&#8217;s precompiled header (.pch) file:</p>
<pre>//force NSLog disable
//uncomment to force NSLog disabling no matter what
//#define FORCE_NSLOG_DISABLE
//note: you will need to add the DEBUG symbol to your
//  project's preprocessor flags setting
#if !defined(DEBUG) || defined(FORCE_NSLOG_DISABLE)
//variadic MACROS may be gcc only
#	define NSLog(...) ;
#endif</pre>
<p>This will replace all NSLog calls to no-ops, which is of course much cheaper than printing to stdout.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://ayumusoft.com/2009/11/303/&amp;t=Strip+you+NSLog%28%29s+automatically&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://ayumusoft.com/2009/11/303/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>avoid really dumb OpenGL texture leaks</title>
		<link>http://ayumusoft.com/2009/04/avoid-really-dumb-opengl-texture-leaks/</link>
		<comments>http://ayumusoft.com/2009/04/avoid-really-dumb-opengl-texture-leaks/#comments</comments>
		<pubDate>Fri, 17 Apr 2009 05:56:21 +0000</pubDate>
		<dc:creator>spike</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[memory management]]></category>
		<category><![CDATA[OpenGL]]></category>

		<guid isPermaLink="false">http://ayumusoft.com/?p=63</guid>
		<description><![CDATA[When you allocate memory for OpenGL textures, something to the tune of glGenTextures(1,&#38;texture);, don&#8217;t don&#8217;t DON&#8217;T forget to free that memory with a glDeleteTextures(1,&#38;texture);. Forgetting to do this tiny little call will result in memory leaks all over the place. Please, spare yourself the sleeplessness.
 ]]></description>
			<content:encoded><![CDATA[<p>When you allocate memory for OpenGL textures, something to the tune of <code>glGenTextures(1,&amp;texture);</code>, don&#8217;t don&#8217;t DON&#8217;T forget to free that memory with a <code>glDeleteTextures(1,&amp;texture);</code>. Forgetting to do this tiny little call will result in memory leaks all over the place. Please, spare yourself the sleeplessness.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://ayumusoft.com/2009/04/avoid-really-dumb-opengl-texture-leaks/&amp;t=avoid+really+dumb+OpenGL+texture+leaks&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://ayumusoft.com/2009/04/avoid-really-dumb-opengl-texture-leaks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>yes, virginia, you CAN do regular expressions in C/C++</title>
		<link>http://ayumusoft.com/2009/04/yes-virginia-you-can-do-regular-expressions-in-cc/</link>
		<comments>http://ayumusoft.com/2009/04/yes-virginia-you-can-do-regular-expressions-in-cc/#comments</comments>
		<pubDate>Fri, 10 Apr 2009 22:00:56 +0000</pubDate>
		<dc:creator>spike</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[c_plus_plus]]></category>
		<category><![CDATA[regex]]></category>

		<guid isPermaLink="false">http://ayumusoft.com/?p=51</guid>
		<description><![CDATA[Regular Expressions in C/C++]]></description>
			<content:encoded><![CDATA[<p>You say you want a regular expression?  Well, you know, you don&#8217;t have to install Perl.</p>
<p>There&#8217;s a few ways you can go about using regular expressions in your C / C++ code.</p>
<ol>
<li>The <a href="http://en.wikipedia.org/wiki/Posix">POSIX</a> C regex library.  This presumes of course you are running on a Unix-ish system, e.g. Linux, Mac OSX, iPhone, BSD, etc.
<pre><code>#include &lt;regex.h&gt;
regex_t re;
const char* re_string = "m[Aa]t?ch.*";
if(regcomp(&amp;re, re_string, REG_NOSUB) != 0){
  std::cerr &lt;&lt; "Invalid regular expression" &lt;&lt; std::endl;
  return;
}
if(regexec(&amp;re, </code><code>"mAchzzzzaaaa!!!!oneone"</code><code>, (size_t)0, NULL, 0) == 0)
  std::cout &lt;&lt; "Found a match!" &lt;&lt; std::endl;
</code></pre>
</li>
<li>The Boost Regex POSIX-like API.  This is a C wrapper to the Boost Regex library, which allows you to use the library with POSIX regex calls.
<pre><code>#include &lt;boost/regex.h&gt;
// otherwise use just as you would the POSIX lib</code></pre>
</li>
<li>The Boost Regex C++ API, straight no chaser.
<pre><code>#include &lt;boost/regex.hpp&gt;
boost::regex re("m[Aa]t?ch.*");
if(boost::regex_match("mAchzzzzaaaa!!!!oneone", re))
  std::cout &lt;&lt; "Found a match!" &lt;&lt; std::end;</code></pre>
</li>
</ol>
<p>This is but a taste of what&#8217;s available.  Peep the <a href="http://opengroup.org/onlinepubs/007908799/xsh/regex.h.html">POSIX regex API</a> and the <a href="http://www.boost.org/doc/libs/1_38_0/libs/regex/doc/html/index.html">Boost Regex Documentation</a>.  Note, Boost Regex is one of only a handful of the Boost packages that needs to be explicitly built and linked with your code.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://ayumusoft.com/2009/04/yes-virginia-you-can-do-regular-expressions-in-cc/&amp;t=yes%2C+virginia%2C+you+CAN+do+regular+expressions+in+C%2FC%2B%2B&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://ayumusoft.com/2009/04/yes-virginia-you-can-do-regular-expressions-in-cc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>get info on a file without opening it from C/C++</title>
		<link>http://ayumusoft.com/2009/04/get-info-on-a-file-opening-it-from-cc/</link>
		<comments>http://ayumusoft.com/2009/04/get-info-on-a-file-opening-it-from-cc/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 02:40:15 +0000</pubDate>
		<dc:creator>spike</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[c_plus_plus]]></category>

		<guid isPermaLink="false">http://ayumusoft.com/?p=28</guid>
		<description><![CDATA[If you need to get info about a file without opening it, you can use &#60;sys/stat.h&#62; to do so.
I needed a way to test the existence of a file.  Version 1 called fopen and tested for NULL, but this also meant some nasty ifs and fclose logic.
Here&#8217;s the better way:

#include &#60;iostream&#62;
#include &#60;cerrno&#62;
#include &#60;sys/stat.h&#62;
struct stat [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to get info about a file without opening it, you can use <code>&lt;sys/stat.h&gt;</code> to do so.</p>
<p>I needed a way to test the existence of a file.  Version 1 called <code>fopen</code> and tested for <code>NULL</code>, but this also meant some nasty <code>if</code>s and <code>fclose</code> logic.</p>
<p>Here&#8217;s the better way:</p>
<pre><code>
#include &lt;iostream&gt;
#include &lt;cerrno&gt;
#include &lt;sys/stat.h&gt;
struct stat fileInfo;
const char* filename = "myFile";
if(stat(filename, &amp;fileInfo) != 0){ //error
  if(errno == ENOENT){
    std::cerr &lt;&lt; "File " &lt;&lt; myFile &lt;&lt; " doesn't exist" &lt;&lt; std::endl;
  else{ //any other error
    std::cerr &lt;&lt; "Error getting info on file " &lt;&lt; filename &lt;&lt; ": "
              &lt;&lt; strerror(errno) &lt;&lt; std::endl;
  }
}
</code></pre>
<p>File existence is but one of the few things you check for.  Just be careful what you check for though, as many of the attributes in <code>struct stat</code> are Unix only.</p>
<p>See <a href="http://opengroup.org/onlinepubs/007908799/xsh/stat.html"><code>stat()</code>&#8217;s documentation</a> for more details.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://ayumusoft.com/2009/04/get-info-on-a-file-opening-it-from-cc/&amp;t=get+info+on+a+file+without+opening+it+from+C%2FC%2B%2B&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://ayumusoft.com/2009/04/get-info-on-a-file-opening-it-from-cc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8216;auto-release pool&#8217; type behavior in C++ with shared_ptr</title>
		<link>http://ayumusoft.com/2009/04/auto-release-pool-type-behavior-in-c-with-shared_ptr/</link>
		<comments>http://ayumusoft.com/2009/04/auto-release-pool-type-behavior-in-c-with-shared_ptr/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 18:36:30 +0000</pubDate>
		<dc:creator>spike</dc:creator>
				<category><![CDATA[tech]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[c_plus_plus]]></category>
		<category><![CDATA[memory management]]></category>

		<guid isPermaLink="false">http://ayumusoft.com/?p=16</guid>
		<description><![CDATA[use boost shared_ptr in std containers for easier memory management]]></description>
			<content:encoded><![CDATA[<p>With boost&#8217;s shared_ptr and standard contaniers, &#8216;auto-release pool&#8217; (as seen in much Obj-C code) type structures can created in C++.</p>
<pre><code>
#include &lt;boost/shared_ptr.hpp&gt;
using boost::shared_ptr;
#include &lt;vector&gt;
class A{...};
typedef shared_ptr&lt;A&gt; A_ptr;
...
vector&lt;A_ptr&gt; vec_of_a;
for(int i = 0; i &lt; 10; i++){
  A_ptr p(new A());
  vec_of_a.push_back(p);
}
...
// do stuff with vector
...
vec_of_a.clear(); //automagically calls delete on all A_ptrs in vector
</code></pre>
<p>To avoid having to call <code>vector::clear()</code>, you can make the vector itself a <code>boost::shared_ptr</code> or <code>boost::scoped_ptr</code>; this will cause the vector itself to be automatically reclaimed, along with its contents.</p>
<p>See <a href="http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/smart_ptr.htm">Boost&#8217;s Smart Pointer Documentation</a> for more info.</p>
<div><table> <td><iframe src='http://digg.com/api/diggthis.php?w=new&amp;u=http://ayumusoft.com/2009/04/auto-release-pool-type-behavior-in-c-with-shared_ptr/&amp;t=%27auto-release+pool%27+type+behavior+in+C%2B%2B+with+shared_ptr&amp;s=normal' height='80' width='52' frameborder='0' scrolling='no'></iframe></td></table></div><!-- This is a HTML comment, it will not display in any page. Feel free to remove this comment if it cause any inconvenient to you.
	Thanks for using digg digg, please visit http://www.mkyong.com/blog/digg-digg-wordpress-plugin for any comments and ideas, 
	
    Author : Yong Mook Kim
    Website : http://www.mkyong.com
	-->]]></content:encoded>
			<wfw:commentRss>http://ayumusoft.com/2009/04/auto-release-pool-type-behavior-in-c-with-shared_ptr/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

