<?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>Coen's blog &#187; c++</title>
	<atom:link href="http://blog.coenbijlsma.nl/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.coenbijlsma.nl</link>
	<description>The blog of Coen Bijlsma (coenie)</description>
	<lastBuildDate>Wed, 26 May 2010 20:55:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>inspectfs</title>
		<link>http://blog.coenbijlsma.nl/2010/05/24/inspectfs/</link>
		<comments>http://blog.coenbijlsma.nl/2010/05/24/inspectfs/#comments</comments>
		<pubDate>Mon, 24 May 2010 11:50:01 +0000</pubDate>
		<dc:creator>coen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[udev]]></category>

		<guid isPermaLink="false">http://blog.coenbijlsma.nl/?p=124</guid>
		<description><![CDATA[It has been some time since my last post here, but finally I have something new to share. Just yet I started working on a hobby project that may end up in the trash, or it may end up as a large side project: inspectfs. I haven&#8217;t put much thought in the name, so if [...]]]></description>
			<content:encoded><![CDATA[<p>It has been some time since my last post here, but finally I have something new to share.<br />
Just yet I started working on a hobby project that may end up in the trash, or it may end up as a large side project: inspectfs. I haven&#8217;t put much thought in the name, so if you have an idea, let me know.<br />
The idea is to build a (Linux) tool that gathers information about any disk / partition / file system that is currently attached to your computer. It&#8217;s a bit of a rough idea as of yet, but I hope it will crystallize a bit in the next few weeks.If you have any ideas or tips regarding this, please let me know and I&#8217;ll see if it&#8217;s worth incorporating.</p>
<p>Inspectfs relies on <a href="http://www.kernel.org/pub/linux/utils/kernel/hotplug/libudev/index.html">libudev</a> for querying device information but I wrote some C++ wrapper classes because I want the project to contain as much C++ and as less C code as possible.<br />
Soon you&#8217;ll be able to find the code and more on <a href="http://github.com/coenbijlsma/libinspectfs">github</a>, and if you want to join me, post a message here!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coenbijlsma.nl/2010/05/24/inspectfs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Valgrind and it&#8217;s neighbours</title>
		<link>http://blog.coenbijlsma.nl/2008/10/12/valgrind-and-its-neighbours/</link>
		<comments>http://blog.coenbijlsma.nl/2008/10/12/valgrind-and-its-neighbours/#comments</comments>
		<pubDate>Sun, 12 Oct 2008 20:15:54 +0000</pubDate>
		<dc:creator>coen</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[gdb]]></category>
		<category><![CDATA[valgrind]]></category>

		<guid isPermaLink="false">http://cbijlsma.homelinux.net/blog/?p=33</guid>
		<description><![CDATA[For some time now, I have been working om my messaging client Skaar. Last week I built a version that only can connect to an IRC-server. There&#8217;s still a lot of work to do, but it was time to test and debug my work done so far. A classmate told me to use valgrind to [...]]]></description>
			<content:encoded><![CDATA[<p>For some time now, I have been working om my messaging client Skaar. Last week I built a version that only can connect to an IRC-server. There&#8217;s still a lot of work to do, but it was time to test and debug my work done so far.</p>
<p>A classmate told me to use valgrind to test Skaar for memory leaks. Valgrind is a suite of tools for debugging and profiling programs, so that should work, and there I went:</p>
<p><code>valgrind --log-file=./valgrind.log --leak-check=full ./skaar</code></p>
<p>After shutting down, it turned out that Skaar had left something behind, and not that modest (43Kb) either. It&#8217;s actually not that simple to prevent memory leaks, I learned. The obvious cases seem to scream: <code>free(3)</code> or <code>delete</code> me, but the not so obvious cases keep their mouths perfectly shut..</p>
<p><strong>Obvious case:</strong><br />
<code>char* line = (char*)malloc(513);<br />
memset(line, 0, 513);<br />
strcpy(line, "PRIVMSG #mychannel :foo\r\n");<br />
...<br />
free(line);<br />
</code><br />
<strong>Not so obvious case:</strong><br />
<code>// in RFC1459.cpp<br />
JoinMessage* joinmessage = new JoinMessage(this, line);<br />
return (AbstractMessage*)joinmessage;</code><br />
<code><br />
// somewhat later in Skaar.cpp<br />
AbstractMessage* message = protocol-&gt;translateIncoming(rawmsg);<br />
...<br />
delete message;<br />
</code></p>
<p>I&#8217;m wondering if this is the right way to end the <code>AbstractMessage*</code>&#8216;s life, by the way. Who&#8217;s responsibility is it to get rid of the message? I could go with this solution, that says: &#8220;Here is your object, have fun&#8221;. I could also create a function in the protocol that destroys the message, something like <code>RFC1459::destroyMessage(AbstractMessage* message)</code>, that says &#8220;Here is your object, but you have to let me take care of it&#8217;s end. Actually, I have no clue which one is the best choice, if there <em>is</em> a best choice here..</p>
<p>But, back to business: all I have to do now is just test every possibility to see if there are any leaks. Or I could just watch it when I write code, which also sounds nice.<br />
Another tool that I&#8217;ve come to value is gdb, The GNU Project Debugger. This tool allows you to see what happens &#8216;inside&#8217; the program while it executes. And yes, I stole that line from gnu.org <img src='http://blog.coenbijlsma.nl/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
To start using gdb is not very hard, just type <code>gdb yourprogram</code>, and that&#8217;s that. To actually start executing you program, type <code>run</code> once gdb has started.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coenbijlsma.nl/2008/10/12/valgrind-and-its-neighbours/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About how school can be enjoyed again</title>
		<link>http://blog.coenbijlsma.nl/2008/02/16/about-how-school-can-be-enjoyed-again/</link>
		<comments>http://blog.coenbijlsma.nl/2008/02/16/about-how-school-can-be-enjoyed-again/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 16:46:23 +0000</pubDate>
		<dc:creator>coen</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[hulk]]></category>
		<category><![CDATA[School]]></category>

		<guid isPermaLink="false">http://blog.coenbijlsma.nl/2008/02/16/about-how-school-can-be-enjoyed-again/</guid>
		<description><![CDATA[Finally I have some time to write another post to you, my dear readers! After starting up the HULK for about a fortnight, we started to bring up ideas for projects (so if anyone has an idea&#8230;). Actually, while I&#8217;m writing this I realize that I haven&#8217;t told you anything yet about the HULK (hmm.. [...]]]></description>
			<content:encoded><![CDATA[<p>Finally I have some time to write another post to you, my dear readers!</p>
<p>After starting up the <a href="http://www.hunix.nl" title="HULK" target="_blank">HULK</a> for about a fortnight, we started to bring up ideas for projects (so if anyone has an idea&#8230;). Actually, while I&#8217;m writing this I realize that I haven&#8217;t told you anything yet about the HULK (hmm.. weird).<br />
Well,  HULK stands for Hogeschool Utrecht Linux Kennisgroep, and consists of a few classmates and yours truly, who try to give Linux a shot in our university, the Hogeschool of Utrecht. The website is in Dutch, so if you want to follow up on it, you have to be able to read it.</p>
<p>We thought about some really cool projects like building our own Ubuntu distribution, HUbuntu , setting up Linux on mobile devices, teaching Unix, and also some smaller projects like building a logbook to keep track of what we&#8217;re doing and to provide student services (SSH access, web servers, database servers, etc.). Apart from that, I&#8217;ve started learning c(++), and for practice I&#8217;m building an IRC client, called skaar.</p>
<p>Next week, together with Mattijs, I&#8217;m starting on the logbook which will be built in PHP, so that we can start logging quickly.</p>
<p>Keeping you posted!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.coenbijlsma.nl/2008/02/16/about-how-school-can-be-enjoyed-again/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
