<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Crash when trying to chance working directory</title>
		<link>http://www.allegro.cc/forums/view/613668</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 22 Dec 2013 10:20:26 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When I try to change directories to load an image with the following code:<br />ALLEGRO_PATH *path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);<br />	const char * pathstr = al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP);<br />	if (!al_change_directory(pathstr))<br />	{<br />		fprintf(stderr, &quot;Erro na mudanca de diretorio.\n&quot;);<br />		return -1;<br />	}<br />the program simply crashes. It&#39;s really weird, since I got the code from older posts so it&#39;s supposed to be working.<br />Also, when I type printf(&quot;%s\n&quot;, al_get_current_directory); it just prints garbage.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hrod Ruck)</author>
		<pubDate>Fri, 20 Dec 2013 19:26:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, <a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">)</span><span class="k2">;</span></span><br />Is this a copy-paste error?<br />Should be<br /><span class="source-code"><a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"%s\n"</span>, <a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span></span></p><p>edit: the above code causes a memory leak. So for proper practice...
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">char</span> <span class="k3">*</span>directory <span class="k3">=</span> <a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
<span class="c">// use variable</span>
<a href="http://www.allegro.cc/manual/al_free"><span class="a">al_free</span></a><span class="k2">(</span>directory<span class="k2">)</span><span class="k2">;</span> <span class="c">// clean up</span>
</pre></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (l j)</author>
		<pubDate>Fri, 20 Dec 2013 20:04:58 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, it was actually an error. Now it prints the directory where my source is. THank you! However, I&#39;ve still got two problems: there is an image there that doesn&#39;t load AND my program crashes when I try to get my current directory.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hrod Ruck)</author>
		<pubDate>Fri, 20 Dec 2013 20:16:17 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>do you call <span class="source-code"><a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a></span> before <span class="source-code"><a href="http://www.allegro.cc/manual/al_get_current_directory"><span class="a">al_get_current_directory</span></a></span>?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (ph03nix)</author>
		<pubDate>Fri, 20 Dec 2013 20:52:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes, that was the case. Thank you.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Hrod Ruck)</author>
		<pubDate>Sun, 22 Dec 2013 10:20:26 +0000</pubDate>
	</item>
</rss>
