<?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>nerthase 2.0 &#187; Tutto il resto</title>
	<atom:link href="http://www.nerthase.com/blog/category/tutto-il-resto/feed" rel="self" type="application/rss+xml" />
	<link>http://www.nerthase.com/blog</link>
	<description>Progettazione... Programmazione... Soluzione...</description>
	<lastBuildDate>Wed, 29 Jun 2011 07:11:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Hacking: SQLInjection con SqlMap</title>
		<link>http://www.nerthase.com/blog/hacking-sqlinjection-con-sqlmap?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hacking-sqlinjection-con-sqlmap</link>
		<comments>http://www.nerthase.com/blog/hacking-sqlinjection-con-sqlmap#comments</comments>
		<pubDate>Tue, 30 Mar 2010 21:19:44 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[PHP & MySql]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[crack]]></category>
		<category><![CDATA[GET]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Guida]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Manuale]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[POST]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Injection]]></category>
		<category><![CDATA[SQLmap]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=499</guid>
		<description><![CDATA[Molte volte ci addentriamo nel mondo del Web, nella creazione di un proprio spazio personale che piano piano si evolve, ma non sempre adottiamo le giuste precauzioni ed i giusti accorgimenti per quanto riguarda la sicurezza. In questi casi, ci viene in aiuto sqlmap, un ottimo tool per l&#8217;analisi delle vulnerabilità presenti in molte applicazioni&#8230;]]></description>
			<content:encoded><![CDATA[<p>Molte volte ci addentriamo nel mondo del Web, nella creazione di un proprio spazio personale che piano piano si evolve, ma non sempre adottiamo le giuste precauzioni ed i giusti accorgimenti per quanto riguarda la sicurezza. In questi casi, ci viene in aiuto <strong><a title="SQL Map - Hacking SQL Injection Tool" href="http://sqlmap.sourceforge.net/" target="_blank">sqlmap</a><span style="font-weight: normal;">, un ottimo tool per l&#8217;analisi delle vulnerabilità presenti in molte applicazioni web che fanno uso di database SQL.</span></strong></p>
<p><img class="aligncenter size-full wp-image-497" title="SQL map" src="http://www.nerthase.com/blog/wp-content/uploads/2010/03/sqlmap.png" alt="" width="218" height="150" /></p>
<h4><span style="font-weight: normal;">Introduzione a SQLmap</span></h4>
<p><strong>SQLmap<span style="font-weight: normal;"> è in grado di automatizzare il processo di analisi di vulnerabilità o exploit ai quali sono soggetti tantissimi server web. SQLmap è scritto in </span>Python<span style="font-weight: normal;">, il che lo rende indipendente dal sistema operativo utilizzato. Per funzionare, richiede solo in </span>interprete Python in versione maggiore o uguale alla 2.5<span style="font-weight: normal;">. Ho già introdotto in precedenti articoli (<a title="Hacking Sql Injection" href="http://www.nerthase.com/blog/hacking-sql-injection" target="_blank">Hacking: SQL Injection</a>, <a title="Difesa e Protezione contro Sql Injection" href="http://www.nerthase.com/blog/difesa-contro-lsql-injection" target="_blank">Difesa contro l’SQL Injection</a>) il concetto di SQLInjection, tutti i pericoli che ne derivano e come difendersi progettando bene la propria applicazione web; ora vediamo come SQLmap riesce nell&#8217;analisi di SQLInjection in modo automatico e preciso.</span></strong> <strong>SQLmap<span style="font-weight: normal;"> implementa tre tecniche per l&#8217;analisi di vulnerabilità per l&#8217;SQL Injection:</span></strong> <strong><span style="font-weight: normal;"> </span></strong></p>
<div id="_mcePaste">
<ol>
<li><strong>Inferential blind SQL injection</strong>, also known as <strong>boolean based blind SQL injection</strong>: sqlmap appends to the affected parameter in the HTTP request, a syntatically valid SQL statement string containing a SELECT sub-statement, or any other SQL statement whose the user want to retrieve the output. For each HTTP response, by making a comparison based upon HTML page content hashes, or string matches, with the original request, the tool determines the output value of the statement character by character. The bisection algorithm implemented in sqlmap to perform this technique is able to fetch each output character with at maximum seven HTTP requests. This is sqlmap default SQL injection technique.</li>
<li><strong>UNION query (inband) SQL injection</strong>, also known as <strong>full UNION query SQL injection</strong>: sqlmap appends to the affected parameter in the HTTP request, a syntatically valid SQL statement string starting with a UNION ALL SELECT. This techique is useful if the web application page passes the output of the SELECT statement to a for cycle, or similar, so that each line of the query output is printed on the page content. sqlmap is also able to exploit <strong>partial (single entry) UNION query SQL injection</strong> vulnerabilities which occur when the output of the statement is not cycled in a for construct whereas only the first entry output is displayed. This technique is much faster if the target url is affected by because in a single HTTP response it returns the whole query output or a entry per each response within the page content. This SQL injection technique is an alternative to the first one.</li>
<li><strong>Batched (stacked) queries support</strong>, also known as <strong>multiple statements support</strong>: sqlmap tests if the web application supports stacked queries then, in case it does support, it appends to the affected parameter in the HTTP request, a semi-colon (;) followed by the SQL statement to be executed. This technique is useful to run SQL statements other than SELECT like, for instance, data definition or data manipulation statements possibly leading to file system read and write access and operating system command execution depending on the underlying back-end database management system and the session user privileges.</li>
</ol>
</div>
<p style="text-align: left;"><div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div></p>
<h4><span style="font-weight: normal;">Uso di SQLmap</span></h4>
<p>SQLmap è un tool molto potente quanto sofisticato. Il suo uso non è molto semplice ed immediato, ma vediamo di imparare ad usarlo con una guida passo passo. Ricordo che è possibile trovare un <strong><a title="Manuale e guida per SqlMap - SQL Injection" href="http://sqlmap.sourceforge.net/doc/README.pdf" target="_blank">manuale molto completo sul sito ufficiale del progetto</a></strong>. Un primo sguardo all&#8217;uso del programma, può essere ottenuto con il comando  <code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -h</span></code>  da digitare nel proprio <strong>Terminale</strong> in Mac OS X o in una qualsiasi console di comando di un sistema operativo Linux o Windows. Questo comando restituisce una lista molto completa e dettagliata di tutti le opzioni di uso del programma.</p>
<p>Un&#8217;opzione molto valida è quella di ottenere un output del programma, analizzando i vari livelli di output. I livelli di <strong>verbosity </strong>(opzione<strong> -v</strong>)<strong> </strong>disponibili sono:</p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot; -v 1</span></code></p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot; -v 2</span></code></p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot; -v 3</span></code></p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot; -v 4</span></code></p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot; -v 5</span></code></p>
<p>L&#8217;opzione <strong>-u</strong> specificata nel comando precedente è obbligatoria e serve per specificare l&#8217;indirizzo da analizzare. Alternativamente, può essere usata l&#8217;opzione <strong>&#8211;url</strong>.</p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py --url &quot;http://172.16.213.131/sqlmap/mysql/get_int.php?id=1&quot;</span></code></p>
<p>Un&#8217;altra modalità di analisi, che non includa direttamente l&#8217;indirizzo web del sito da analizzare, è quella di specificare un file contenente una <strong>richiesta HTTP</strong> valida, che quindi SQLmap effettuerà analizzando i risultati (opzione <strong>-r</strong>). In questo caso, deve esistere un file contenente la richiesta HTTP in questo modo:</p>
<div class="codecolorer-container text mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">POST /sqlmap/mysql/post_int.php<br />
<br />
HTTP/1.1 &nbsp;Host: 172.16.213.131<br />
<br />
User-Agent: Mozilla/4.0<br />
<br />
id=1</div></div>
<p>e quindi l&#8217;applicazione SQLmap dovrà essere eseguita nel modo seguente:</p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -r request.txt</span></code></p>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<p>Una funzionalità ancora più interessante, consiste nell&#8217;analizzare un intero sito web, alla ricerca di tutte le possibili vulnerabilità. Questa feature è possibile grazie all&#8217;appoggio di Google, che è in grado di restituire risultati relativi ad un <strong>singolo dominio</strong> specificando ulteriori opzioni (opzione <strong>-g</strong> del programma SQLmap). Il comando diventa quindi:</p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -g &quot;site:yourdomain.com ext:php&quot; -v 1</span></code></p>
<p>In questo caso SQLmap analizzerà i primi 100 risultati di Google relativi al dominio specificato, alla ricerca di risultati che contengano al loro interno richieste <strong>GET</strong>, in modo da poter verificare la presenza di possibili vulnerabilità.</p>
<p>SQLmap non è in grado di analizzare solo applicazioni web che fanno uso di richieste <strong>GET</strong>, ma anche quei servizi che per maggiore protezione, fanno uso di richieste <strong>POST</strong>. In questo caso entrano in gioco le opzioni <strong>&#8211;method </strong>e<strong> &#8211;data </strong>di SQLmap:</p>
<p><code class="codecolorer text mac-classic"><span class="text">python sqlmap.py -u &quot;http://test-site.it/test-page.php&quot; --method POST --data &quot;id=1&quot;</span></code></p>
<p>Queste sono solo alcune situazioni di utilizzo di SQLmap, è possibile trovarne altre sul <a title="Manuale e Guida per SQLmap - SQL Injection" href="http://sqlmap.sourceforge.net/doc/README.pdf" target="_blank">manuale ufficiale</a> presente sul sito web del programma. Di seguito uno dei <a title="Video Guida SQL map" href="http://sqlmap.sourceforge.net/demo.html" target="_blank">video ufficiali</a> per l&#8217;uso del programma disponibili anch&#8217;essi sul sito web del programma:</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="480" height="385" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/fGBQm9Nfn24&amp;hl=it_IT&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="480" height="385" src="http://www.youtube.com/v/fGBQm9Nfn24&amp;hl=it_IT&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/hacking-sqlinjection-con-sqlmap/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Buddy System con MallocLab</title>
		<link>http://www.nerthase.com/blog/buddy-system-con-malloclab?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=buddy-system-con-malloclab</link>
		<comments>http://www.nerthase.com/blog/buddy-system-con-malloclab#comments</comments>
		<pubDate>Sat, 27 Mar 2010 21:15:46 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Mondo Linux]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[albero binario]]></category>
		<category><![CDATA[algoritmi]]></category>
		<category><![CDATA[allocatore di memoria]]></category>
		<category><![CDATA[buddy system]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[demetrescu]]></category>
		<category><![CDATA[ingegneria]]></category>
		<category><![CDATA[malloc]]></category>
		<category><![CDATA[malloclab]]></category>
		<category><![CDATA[programmazione]]></category>
		<category><![CDATA[realloc]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=486</guid>
		<description><![CDATA[Dopo avervi parlato dei vari progetti che ho svolto recentemente in Università, voglio condividere con voi anche un progetto molto interessante che ho realizzato 2 anni fa. Si tratta di un allocatore di memoria, quindi di un argomento abbastanza di basso livello, non facilmente comprensibile ai più novizi. Questo progetto mi è stato assegnato durante&#8230;]]></description>
			<content:encoded><![CDATA[<p>Dopo avervi parlato dei vari progetti che ho svolto recentemente in Università, voglio condividere con voi anche un progetto molto interessante che ho realizzato 2 anni fa. Si tratta di un allocatore di memoria, quindi di un argomento abbastanza di basso livello, non facilmente comprensibile ai più novizi. Questo progetto mi è stato assegnato durante il corso di <a title="Ingegneria degli Algoritmi - Camil Demetrescu" href="http://www.dis.uniroma1.it/~demetres/didattica/ae2009/" target="_blank">Ingegneria degli Algoritmi</a> dal mio caro prof. <a title="Camil Demetrescu" href="http://www.dis.uniroma1.it/~demetres/" target="_blank">Camil Demetrescu</a>, indubbiamente uno dei migliori professori che abbia mai incontrato.</p>
<h4>Descrizione</h4>
<p>Lo scopo del progetto è quello di realizzare un allocatore di memoria (usando il <strong>linguaggio C</strong>) e paragonarne l&#8217;efficienza con l&#8217;allocatore di memoria predefinito di sistema (la classica <strong>malloc</strong> in C). Per eseguire questi test ho usato un framework chiamato <strong>MallocLab</strong> che prende in input l&#8217;allocatore di memoria da me realizzato, esegue alcuni test su sequenze reali di <strong>malloc</strong>,<strong> free </strong>e<strong> realloc</strong> e assegna un punteggio all&#8217;allocatore, in base al suo comportamento rispetto all&#8217;allocatore di memoria di sistema.</p>
<p>Di seguito sono disponibili per il download il package di <strong>MallocLab</strong> ed un suo esempio di uso:</p>
<ol>
<li><a title="MallocLab - Package di test per allocatore di memoria" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/malloclab-ae.zip">Package sperimentale MallocLab</a>;</li>
<li><a title="Specifiche e guida d'uso per MallocLab" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/malloclab-spec.pdf" target="_blank">Guida all&#8217;uso di MallocLab</a>;</li>
<li><a title="Guida d'uso per MallocLab" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/malloclab-readme.txt" target="_blank">MallocLab readme</a>.</li>
</ol>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<p>Dopo questa breve introduzione agli strumenti necessari per la comprensione di questo progetto, passo a parlarvi della mia soluzione. Come evidente nel titolo, la mia soluzione per l&#8217;allocatore di memoria è basata sulla tecnica del <strong>Buddy System</strong>.</p>
<p><cite title="Buddy System - Wikipedia">Il </cite><strong><cite title="Buddy System - Wikipedia">Buddy System</cite></strong><cite title="Buddy System - Wikipedia"> o </cite><strong><cite title="Buddy System - Wikipedia">buddy memory allocation</cite></strong><cite title="Buddy System - Wikipedia"> è una tecnica di allocazione dinamica della memoria che divide la memoria in partizioni per soddisfare una richiesta di memoria nel miglior modo possibile. Questo sistema suddivide ricorsivamente la memoria in due metà finché il blocco ottenuto è grande appena a sufficienza per l&#8217;uso, cioè quando un&#8217;ulteriore divisione lo renderebbe più piccolo della dimensione richiesta.</cite></p>
<p>Da questa definizione (tratta da Wikipedia) potete immaginare che il Buddy System lavori come un <strong>albero binario</strong>. Questo è evidente per quanto riguarda chiamate alla funzione <strong>malloc</strong>, mentre è meno intuitivo quando si libera una porzione di memoria con la funzione <strong>free</strong>. In questo caso, il blocco viene liberato, e se possibile, viene riunito con il blocco fratello (per questo è necessario immaginare che il Buddy System lavori come un grande albero binario).</p>
<h4>Soluzione adottata</h4>
<p>Di seguito un segmento della relazione del progetto, per capire meglio la tecnica utilizzata:</p>
<p><strong>Soluzione adottata</strong></p>
<p style="padding-left: 30px;">Il progetto è stato sviluppato usando la tecnica del Buddy System Binario come strategia di allocazione di memoria.</p>
<p><strong>Categorie e dimensioni dei blocchi</strong></p>
<p style="padding-left: 30px;">Nel Buddy System Binario adottato si hanno le stesse proprietà descritte nelle specifiche, in particolare, le categorie di blocchi, e quindi la dimensione dei blocchi utilizzati, è 2k con k = 6, 7, &#8230;, 24, (ovvero dimensioni che vanno da 64 Bytes, a 16 Mega Bytes).</p>
<p style="padding-left: 30px;">Il limite inferiore di 64B è stato fissato perché sperimentalmente è stato trovato che non venivano effettuate eccessive richieste di blocchi di dimensione inferiore ai 64B.</p>
<p style="padding-left: 30px;">Il limite superiore di 16MB è stato dettato dal driver, in quanto impone un limite di 20MB alla dimensione dell’heap, e quindi era inutile considerare blocchi di dimensione superiore ai 16 MB (ovvero 32MB, 64MB, &#8230;).</p>
<p style="padding-left: 30px;">Per tenere traccia delle 19 categorie, viene mantenuto in memoria un array con indici da 0 a 18, e nella cella di posizione <em>i </em>dell’array, viene mantenuta una lista collegata dei blocchi liberi appartenenti a quella categoria.</p>
<p><strong>Operazione di fusione di blocchi compagni</strong></p>
<p style="padding-left: 30px;">Nella soluzione adottata, inoltre, la fusione di blocchi compagni non viene effettuata appena possibile, ma viene effettuata ogni 1500 chiamate alla funzione <em>mm_free</em>; in particolare vengono esaminati tutti i blocchi liberi presenti in memoria, e si verifica se è possibile fonderli con i rispettivi compagni. In questo modo il costo medio della funzione <em>mm_free </em>diminuisce, in quanto solo una chiamata ogni 1500 provoca rallentamento dovuto alla fusione dei blocchi.</p>
<p><strong>Informazioni di controllo</strong></p>
<p style="padding-left: 30px;">Il modo in cui vengono gestite le informazioni di controllo, differiscono leggermente a seconda dello stato del blocco:</p>
<p style="padding-left: 30px;"><strong>Sia per i blocchi liberi che per i blocchi allocati</strong>, vengono mantenute informazioni necessarie per identificare il tipo e lo stato del blocco:</p>
<ul>
<li>la categoria a cui il blocco appartiene, e quindi indirettamente la dimensione del blocco;</li>
<li>un valore che indica se il blocco è attualmente in uso o è libero.</li>
</ul>
<p style="padding-left: 30px;"><strong>Per i blocchi liberi </strong>oltre alle informazioni usate per i blocchi allocati (necessarie per identificare il tipo e lo stato del blocco), vengono mantenute delle informazioni per gestire le liste collegate dei blocchi liberi:</p>
<ul>
<li>un valore che indica se il blocco ha un successore nella lista dei blocchi liberi della stessa categoria;</li>
<li>l’indirizzo del successore. Queste informazioni vengono mantenute secondo il seguente schema:</li>
<li>Le informazioni in rosso sono considerate per i soli blocchi liberi, in particolare, nei blocchi in uso, i 4 Byte riservati all’indirizzo del blocco successore nella lista collegata, diventano parte del <em>Payload </em>del blocco.</li>
</ul>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="MallocLab header" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/MallocLab-header.png"><img class="aligncenter size-full wp-image-487" title="MallocLab header" src="http://www.nerthase.com/blog/wp-content/uploads/2010/03/MallocLab-header.png" alt="" width="600" height="120" /></a></p>
<p><strong>Vantaggi:</strong></p>
<ul>
<li>semplicità di implementazione, per quanto riguarda i controlli da effettuare;</li>
<li>allineamento agli 8 Byte implicito, in quanto una volta allineato il primo blocco, tutti gli altri risulteranno allineati perché tutti di dimensione multipla di 8 Byte;</li>
<li>velocità di esecuzione, dovuta soprattutto ai punti precedenti;</li>
<li>occupazione minima delle informazioni di controllo, che praticamente sono contenute in un solo Byte.</li>
</ul>
<p><strong>Svantaggi:</strong></p>
<ul>
<li>si hanno solamente 19 categorie, e l’intervallo tra una categoria e quella successiva non è minimale;</li>
<li>la memoria non utilizzata, ma allocata, in un blocco è al più pari alla metà della dimensione del blocco, in quanto per una richiesta di 2k + 1 Bytes, viene allocato un blocco di dimensione 2k+1 Bytes.</li>
</ul>
<h4>Implementazione in C</h4>
<p>Di seguito il codice C del mio allocatore di memoria:</p>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<div class="codecolorer-container c mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br />65<br />66<br />67<br />68<br />69<br />70<br />71<br />72<br />73<br />74<br />75<br />76<br />77<br />78<br />79<br />80<br />81<br />82<br />83<br />84<br />85<br />86<br />87<br />88<br />89<br />90<br />91<br />92<br />93<br />94<br />95<br />96<br />97<br />98<br />99<br />100<br />101<br />102<br />103<br />104<br />105<br />106<br />107<br />108<br />109<br />110<br />111<br />112<br />113<br />114<br />115<br />116<br />117<br />118<br />119<br />120<br />121<br />122<br />123<br />124<br />125<br />126<br />127<br />128<br />129<br />130<br />131<br />132<br />133<br />134<br />135<br />136<br />137<br />138<br />139<br />140<br />141<br />142<br />143<br />144<br />145<br />146<br />147<br />148<br />149<br />150<br />151<br />152<br />153<br />154<br />155<br />156<br />157<br />158<br />159<br />160<br />161<br />162<br />163<br />164<br />165<br />166<br />167<br />168<br />169<br />170<br />171<br />172<br />173<br />174<br />175<br />176<br />177<br />178<br />179<br />180<br />181<br />182<br />183<br />184<br />185<br />186<br />187<br />188<br />189<br />190<br />191<br />192<br />193<br />194<br />195<br />196<br />197<br />198<br />199<br />200<br />201<br />202<br />203<br />204<br />205<br />206<br />207<br />208<br />209<br />210<br />211<br />212<br />213<br />214<br />215<br />216<br />217<br />218<br />219<br />220<br />221<br />222<br />223<br />224<br />225<br />226<br />227<br />228<br />229<br />230<br />231<br />232<br />233<br />234<br />235<br />236<br />237<br />238<br />239<br />240<br />241<br />242<br />243<br />244<br />245<br />246<br />247<br />248<br />249<br />250<br />251<br />252<br />253<br />254<br />255<br />256<br />257<br />258<br />259<br />260<br />261<br />262<br />263<br />264<br />265<br />266<br />267<br />268<br />269<br />270<br />271<br />272<br />273<br />274<br />275<br />276<br />277<br />278<br />279<br />280<br />281<br />282<br />283<br />284<br />285<br />286<br />287<br />288<br />289<br />290<br />291<br />292<br />293<br />294<br />295<br />296<br />297<br />298<br />299<br />300<br />301<br />302<br />303<br />304<br />305<br />306<br />307<br />308<br />309<br />310<br />311<br />312<br />313<br />314<br />315<br />316<br />317<br />318<br />319<br />320<br />321<br />322<br />323<br />324<br />325<br />326<br />327<br />328<br />329<br />330<br />331<br />332<br />333<br />334<br />335<br />336<br />337<br />338<br />339<br />340<br />341<br />342<br />343<br />344<br />345<br />346<br />347<br />348<br />349<br />350<br />351<br />352<br />353<br />354<br />355<br />356<br />357<br />358<br />359<br />360<br />361<br />362<br />363<br />364<br />365<br />366<br />367<br />368<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &quot;mm.h&quot;</span><br />
<span style="color: #339933;">#include &quot;memlib.h&quot;</span><br />
<br />
team_t team <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Team name */</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">&quot;N Team&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* First member's full name */</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">&quot;nerthase&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* First member's email address */</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">&quot;webmaster@nerthase.com&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Second member's full name (leave blank if none) */</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">&quot;&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/* Second member's email address (leave blank if none) */</span><br />
&nbsp; &nbsp; <span style="color: #ff0000;">&quot;&quot;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">typedef</span> <span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span> u_int<span style="color: #339933;">;</span><br />
<br />
<span style="color: #339933;">#define STRUCT_ELEM 19</span><br />
<span style="color: #339933;">#define STRUCT_ELEM_SIZE 4</span><br />
<span style="color: #339933;">#define STRUCT_SIZE ( STRUCT_ELEM * STRUCT_ELEM_SIZE )</span><br />
<span style="color: #339933;">#define HEADER_SIZE 1</span><br />
<br />
<span style="color: #339933;">#define PACK(index, state) ( ((index) | ((state) &lt;&lt; 7)) &amp; 0x9F )&nbsp; &nbsp; //vedi righe seguenti per la struttura</span><br />
<span style="color: #339933;">#define SET_HEADER(addr, byte) { *(addr) = (byte); } //inserisce nel byte all'indirizzo addr, il byte byte</span><br />
<span style="color: #339933;">#define SET_NEXT(addr, next) { if ((next) != 0) { *(addr) = ((*(addr)) | 0x40); *((u_int *) ((addr) + HEADER_SIZE)) = (next); } else { *(addr) = ((*(addr)) &amp; 0xBF); } } //imposta il next nel blocco di indirizzo addr</span><br />
<br />
<span style="color: #339933;">#define INDEX(header) ( (*((char *) (header))) &amp; 0x1F ) //l'indice della categoria è nei 5 bit meno significativi del primo byte del blocco</span><br />
<span style="color: #339933;">#define STATUS(header) ( ((*((char *) (header))) &amp; 0x80) &gt;&gt; 7 ) //lo stato è nel bit più significativo del primo byte del blocco</span><br />
<span style="color: #339933;">#define HAS_NEXT(header) ( ((*((char *) (header))) &amp; 0x40) &gt;&gt; 6 ) //il bit che mi indica se un blocco ha un next, è il secondo bit del primo byte</span><br />
<span style="color: #339933;">#define NEXT(header) ( (HAS_NEXT((header))) ? ((char *) (*((u_int *) ((header) + HEADER_SIZE)))) : 0) //il next è nei byte 2-5 del blocco</span><br />
<br />
<span style="color: #666666; font-style: italic;">//arg è la dimensione del blocco, res sarà l'indice dei blocchi più piccoli che possono contenere quella dimensione </span><br />
<span style="color: #339933;">#define SIZE2INDEX(res, size) { size_t _tmp = 32; for (res = 6 ; res &lt; STRUCT_ELEM + 6 ; ++res) { _tmp = _tmp * 2; if (_tmp &gt;= (size)) break; } res = res - 6; }</span><br />
<br />
<span style="color: #666666; font-style: italic;">//esp è l'indice nella struttura, res sarà la dimensione dei blocchi a indice esp</span><br />
<span style="color: #339933;">#define INDEX2SIZE(res, index) { int _esp; int _i = (index) + 6; res = 32; for (_esp = 6 ; _esp &lt;= _i ; ++_esp) { res = res * 2; } }</span><br />
<br />
<span style="color: #666666; font-style: italic;">//calcola l'indirizzo di struct[i]</span><br />
<span style="color: #339933;">#define STRUCT(i) ( (heap_addr) + 4*(i) )</span><br />
<br />
<span style="color: #666666; font-style: italic;">//inserisce un blocco nella struttura (in testa alla lista)</span><br />
<span style="color: #339933;">#define ADD_BLOCK(addr) { int _i = INDEX(addr); SET_NEXT((addr), (*((u_int *) (STRUCT(_i))))); *((u_int *) STRUCT(_i)) = ((u_int) (addr)); }</span><br />
<br />
<span style="color: #666666; font-style: italic;">//rimuove il primo blocco di indice i, cancella l'header, e &quot;ritorna&quot; l'indirizzo del blocco appena eliminato</span><br />
<span style="color: #339933;">#define REMOVE_FIRST_BLOCK(b_addr, index) { b_addr = ((char *) (*((u_int *) STRUCT(index)))); *((u_int *) STRUCT(index)) = ((u_int) NEXT(b_addr)); SET_HEADER(b_addr, PACK(0, 0)); }</span><br />
<br />
<span style="color: #993333;">int</span> c<span style="color: #339933;">;</span><br />
<span style="color: #993333;">char</span> &nbsp;<span style="color: #339933;">*</span>heap_addr<span style="color: #339933;">;</span><br />
<span style="color: #993333;">size_t</span> heap_size<span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//taglia dell'heap effettivo, quindi senza la struttura</span><br />
<br />
<span style="color: #993333;">char</span> <span style="color: #339933;">*</span>get_buddy <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; u_int offset<span style="color: #339933;">,</span> min<span style="color: #339933;">,</span> max<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buddy<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> INDEX<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; min <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> heap_addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> STRUCT_SIZE<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; max <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> heap_addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> STRUCT_SIZE <span style="color: #339933;">+</span> heap_size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; offset <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> min<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>offset <span style="color: #339933;">%</span> <span style="color: #009900;">&#40;</span>size <span style="color: #339933;">*</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span> <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; buddy <span style="color: #339933;">=</span> addr <span style="color: #339933;">+</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; buddy <span style="color: #339933;">=</span> addr <span style="color: #339933;">-</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//verifico se il buddy è nell'heap</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> buddy <span style="color: #339933;">&lt;</span> min <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> buddy <span style="color: #339933;">&gt;=</span> max<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> INDEX<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> INDEX<span style="color: #009900;">&#40;</span>buddy<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> STATUS<span style="color: #009900;">&#40;</span>buddy<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> buddy<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> remove_block <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> index <span style="color: #339933;">=</span> INDEX<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>p<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>next<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; p <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> STRUCT<span style="color: #009900;">&#40;</span>index<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> p <span style="color: #339933;">==</span> addr <span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; REMOVE_FIRST_BLOCK<span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//scandisco la lista fino a che non mi posiziono su blocco prima di quello da rimuovere</span><br />
&nbsp; &nbsp; next <span style="color: #339933;">=</span> NEXT<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>next <span style="color: #339933;">!=</span> addr<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; p <span style="color: #339933;">=</span> next<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; next <span style="color: #339933;">=</span> NEXT<span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//rimuovo il blocco</span><br />
&nbsp; &nbsp; SET_NEXT<span style="color: #009900;">&#40;</span>p<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> NEXT<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//elimino le informazioni dal blocco</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>addr<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> coalesce <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buddy<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>new_addr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> index <span style="color: #339933;">=</span> INDEX<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>index <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//trovo il buddy</span><br />
&nbsp; &nbsp; buddy <span style="color: #339933;">=</span> get_buddy<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buddy <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//stabilisco come sono ordinati</span><br />
&nbsp; &nbsp; new_addr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>buddy <span style="color: #339933;">&gt;</span> addr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> addr <span style="color: #339933;">:</span> buddy<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//li rimuovo</span><br />
&nbsp; &nbsp; remove_block<span style="color: #009900;">&#40;</span>buddy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; remove_block<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//inserisco il blocco di dimensione doppia</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>new_addr<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>new_addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> split <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> i<span style="color: #009900;">&#41;</span>&nbsp; <span style="color: #666666; font-style: italic;">//Splitta il primo blocco di indice i nella struttura</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>b_addr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr1<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>addr2<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//rimuovo il blocco dalla struttura</span><br />
&nbsp; &nbsp; REMOVE_FIRST_BLOCK<span style="color: #009900;">&#40;</span>b_addr<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//splitto il blocco</span><br />
&nbsp; &nbsp; addr1 <span style="color: #339933;">=</span> b_addr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; addr2 <span style="color: #339933;">=</span> b_addr <span style="color: #339933;">+</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//preparo i due nuovi blocchi e li inserisco nella struttura</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>addr1<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>addr1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>addr2<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>addr2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> expand_heap <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> index<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>new<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> max<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>max<span style="color: #339933;">,</span> <span style="color: #0000dd;">18</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>heap_size <span style="color: #339933;">&lt;</span> max<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; new <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> mem_sbrk<span style="color: #009900;">&#40;</span>heap_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//inserisco il nuovo blocco nella struttura</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SIZE2INDEX<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> heap_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>new<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>new<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; heap_size <span style="color: #339933;">=</span> heap_size <span style="color: #339933;">*</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #666666; font-style: italic;">//vuol dire che l'heap è arrivato a 16M, quindi posso permettermi solo altri 4M (quasi :D)</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">size_t</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> <span style="color: #0000dd;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//alloco blocchi di dimensione fissa 128k (11)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; new <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> mem_sbrk<span style="color: #009900;">&#40;</span>size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SIZE2INDEX<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>new<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>new<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>coalesce<span style="color: #009900;">&#40;</span>new<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; heap_size <span style="color: #339933;">=</span> heap_size <span style="color: #339933;">+</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> find_block <span style="color: #009900;">&#40;</span><span style="color: #993333;">size_t</span> size<span style="color: #009900;">&#41;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//trova un blocco libero che può contenere size byte e ne restituisce l'indice, altrimenti -1</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">,</span> index<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> b_size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; SIZE2INDEX<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//ottengo l'indice del blocco più piccolo che può contenere size byte</span><br />
&nbsp; &nbsp; <br />
<br />
search<span style="color: #339933;">:</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//trovo il primo blocco disponibile</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> index <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> STRUCT_ELEM <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>b_size<span style="color: #339933;">,</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; <span style="color: #666666; font-style: italic;">//ottengo la taglia dei blocchi di indice i</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>b_size <span style="color: #339933;">&gt;</span> heap_size<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//se sono di taglia maggiore della dimensione dell'heap, devo sicuramente espandere</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; expand_heap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> i <span style="color: #339933;">-</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> index <span style="color: #339933;">-</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span> i <span style="color: #339933;">=</span> index <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//riaggiusto gli indici in modo da riconsiderare il blocco appena creato</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>STRUCT<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//se non ci sono blocchi nella struttura di dimensione adeguata, continuo a cercare oltre</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">==</span> STRUCT_ELEM<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//return -1;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; expand_heap<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">goto</span> search<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//splitto il blocco fino ad arrivare ad uno di dimensione b_size</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> index <span style="color: #339933;">;</span> <span style="color: #339933;">--</span>i<span style="color: #009900;">&#41;</span> split<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> index<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> mm_init<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; u_int <span style="color: #339933;">*</span>p<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//allineo l'heap a 8 byte (in realtà allineo la parte del blocco che restituisco nella malloc)</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;=</span> <span style="color: #0000dd;">8</span> <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; u_int tmp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> mem_sbrk<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//alloco un byte per volta</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>tmp <span style="color: #339933;">+</span> STRUCT_SIZE<span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">6</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//quando il byte allocato ha come resto 6, significa che il prossimo blocco allocato sarà allineato a 7 byte</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//ma l'indirizzo che restituisco nella malloc, sarà allocato quindi a 8 byte come richiesto</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>heap_size<span style="color: #339933;">,</span> <span style="color: #0000dd;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; heap_addr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> mem_sbrk<span style="color: #009900;">&#40;</span>STRUCT_SIZE <span style="color: #339933;">+</span> heap_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> STRUCT_ELEM <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//scrivo 0 in tutte le celle della struttura (4 byte)</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> STRUCT<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; SIZE2INDEX<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> heap_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//trovo l'indice del blocco di dimensione heap_size</span><br />
&nbsp; &nbsp; p <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>u_int <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> STRUCT<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//ottengo l'indirizzo all'interno della struttura dei blocchi di quella dimensione</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #339933;">*</span>p <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span>heap_addr <span style="color: #339933;">+</span> STRUCT_SIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//inserisco il primo blocco allocato, quello di dimensione heap_size</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span>p<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//imposto adeguatamente l'header del blocco</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>mm_malloc<span style="color: #009900;">&#40;</span><span style="color: #993333;">size_t</span> size<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>block<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> index<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; index <span style="color: #339933;">=</span> find_block<span style="color: #009900;">&#40;</span>HEADER_SIZE <span style="color: #339933;">+</span> size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>index <span style="color: #339933;">==</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> NULL<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; REMOVE_FIRST_BLOCK<span style="color: #009900;">&#40;</span>block<span style="color: #339933;">,</span> index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>block<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> block <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> mm_free<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span>ptr<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>b_addr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> ptr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> index <span style="color: #339933;">=</span> INDEX<span style="color: #009900;">&#40;</span>b_addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>b_addr<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>index<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>b_addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">++</span>c <span style="color: #339933;">%</span> <span style="color: #0000dd;">1500</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> STRUCT_ELEM <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addr <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> STRUCT<span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>tmp <span style="color: #339933;">=</span> addr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>addr <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; addr <span style="color: #339933;">=</span> NEXT<span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; coalesce<span style="color: #009900;">&#40;</span>tmp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> split_2 <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>block<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #666666; font-style: italic;">// Splitta un blocco che non è nella struttura</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// In particolare lascia la prima metà di blocco invariata</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// e la seconda la azzera e la inserisce nella struttura</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>addr1<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>addr2<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> INDEX<span style="color: #009900;">&#40;</span>block<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//splitto il blocco</span><br />
&nbsp; &nbsp; addr1 <span style="color: #339933;">=</span> block<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; addr2 <span style="color: #339933;">=</span> block <span style="color: #339933;">+</span> size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Il primo blocco cambia solo di dimensione</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>addr1<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Il secondo invece viene anche inserito nella struttura</span><br />
&nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>addr2<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>i <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; ADD_BLOCK<span style="color: #009900;">&#40;</span>addr2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> <span style="color: #339933;">*</span>mm_realloc<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span>ptr<span style="color: #339933;">,</span> <span style="color: #993333;">size_t</span> new_size<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>old <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> ptr<span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>new<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">size_t</span> old_size<span style="color: #339933;">,</span> const_old_size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> old_index <span style="color: #339933;">=</span> INDEX<span style="color: #009900;">&#40;</span>old<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//ottengo la taglia del blocco vecchio</span><br />
&nbsp; &nbsp; INDEX2SIZE<span style="color: #009900;">&#40;</span>old_size<span style="color: #339933;">,</span> old_index<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; const_old_size <span style="color: #339933;">=</span> old_size<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>new_size <span style="color: #339933;">&lt;</span> old_size <span style="color: #339933;">&amp;&amp;</span> new_size <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span>old_size <span style="color: #339933;">/</span> <span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> old <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>new_size <span style="color: #339933;">&lt;</span> old_size<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//sono sicuro che è anche minore della metà</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">int</span> new_index<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; SIZE2INDEX<span style="color: #009900;">&#40;</span>new_index<span style="color: #339933;">,</span> new_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//è sicuramente minore di old_index</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> old_index <span style="color: #339933;">;</span> i <span style="color: #339933;">&gt;</span> new_index <span style="color: #339933;">;</span> <span style="color: #339933;">--</span>i<span style="color: #009900;">&#41;</span> split_2<span style="color: #009900;">&#40;</span>old<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> old <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>new_size <span style="color: #339933;">&gt;=</span> old_size<span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">// vedo se posso fare il coalesce con il blocco alla sua destra</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buddy <span style="color: #339933;">=</span> get_buddy<span style="color: #009900;">&#40;</span>old<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> buddy <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> buddy <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span>u_int<span style="color: #009900;">&#41;</span> old<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">goto</span> nuovo<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">else</span> <span style="color: #666666; font-style: italic;">//posso unire i 2 blocchi</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; remove_block<span style="color: #009900;">&#40;</span>buddy<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; old_size <span style="color: #339933;">=</span> old_size <span style="color: #339933;">*</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; old_index <span style="color: #339933;">=</span> old_index <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; SET_HEADER<span style="color: #009900;">&#40;</span>old<span style="color: #339933;">,</span> PACK<span style="color: #009900;">&#40;</span>old_index<span style="color: #339933;">,</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// se arrivo qui, significa che facendo il coalesce progressivo di blocchi vicini, sono arrivato ad un blocco della taglia desiderata :D</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> old <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <br />
nuovo<span style="color: #339933;">:</span>&nbsp; <span style="color: #666666; font-style: italic;">// non posso fare altro che allocare un nuovo blocco e copiare il contenuto</span><br />
&nbsp; &nbsp; new <span style="color: #339933;">=</span> mm_malloc<span style="color: #009900;">&#40;</span>new_size<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span> <span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> const_old_size <span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>new <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>old <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span> <span style="color: #339933;">+</span> i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; mm_free<span style="color: #009900;">&#40;</span>ptr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> new<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Lo sviluppo di questo progetto mi ha richiesto molto tempo e fatiche, ma devo dire che ne è valsa indubbiamente la pena, in quanto ho scoperto che il C è un linguaggio dalle potenzialità <em>infinite</em>. Concludendo, vi metto a disposizione per il download, il mio allocatore e la relazione (molto semplice) che ho scritto per presentare il progetto:</p>
<ul>
<li><a title="Allocatore di memoria con Buddy System" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/mm-buddy.c" target="_blank">Codice sorgente del Buddy System</a>;</li>
<li><a title="Allocatore di memoria con Buddy System e MallocLab" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/malloclab-tesina.pdf" target="_blank">Relazione del progetto</a>.</li>
</ul>
<p>Se avete dubbi o domande su tecniche utilizzate, non fatevi alcun problema a chiedere.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/buddy-system-con-malloclab/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creare RSS per tutti i siti</title>
		<link>http://www.nerthase.com/blog/creare-rss-per-tutti-i-siti?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=creare-rss-per-tutti-i-siti</link>
		<comments>http://www.nerthase.com/blog/creare-rss-per-tutti-i-siti#comments</comments>
		<pubDate>Tue, 16 Mar 2010 21:24:26 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Feedity]]></category>
		<category><![CDATA[RSS]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=375</guid>
		<description><![CDATA[Spesso mi capita di dover seguire siti web di alcuni miei professori, che non hanno a disposizione i feed RSS. Fino ad oggi usavo alcuni siti web che promettono di controllare gli aggiornamenti della pagina al posto tuo, e di notificarti le novità. Questi siti però non hanno una vita lunga, anzi, spesso funzionano per&#8230;]]></description>
			<content:encoded><![CDATA[<p>Spesso mi capita di dover seguire siti web di alcuni miei professori, che non hanno a disposizione i <strong>feed RSS</strong>. Fino ad oggi usavo alcuni siti web che promettono di controllare gli aggiornamenti della pagina al posto tuo, e di notificarti le novità. Questi siti però non hanno una vita lunga, anzi, spesso funzionano per poco tempo, fino a quando hanno un numero limitato di utenti. Oggi invece ho scoperto <strong><a title="Feedity - RSS per tutti" href="http://feedity.com/" target="_blank">Feedity</a></strong>.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
<a title="Feedity - RSS per tutti" href="http://feedity.com/" target="_blank">Feedity</a> è un servizio web che crea i <strong>feed RSS</strong> anche per i siti che non li mettono a disposizione. Questa funzionalità è molto utile, in quanto ognuno di noi può creare un feed RSS per un sito di interesse, e soprattutto possono essere effettuate molte personalizzazione.</p>
<p style="text-align: left;"><a class="lightbox" title="Feedity" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/Feedity.png"><img class="aligncenter size-full wp-image-376" title="Feedity" src="http://www.nerthase.com/blog/wp-content/uploads/2010/03/Feedity.png" alt="" width="541" height="388" /></a></p>
<p style="text-align: left;">La cosa più interessante di questo servizio, è la creazione di un canale di feed personale, per ogni sito che si desidera monitorare. Sarà quindi possibile seguire i propri feed (creati tramite Feedity) con il lettore di RSS che si preferisce. Unica nota dolente, è che l&#8217;account gratuito notifica un <em>massimo di 10 aggiornamenti per pagina</em>, non immediatamente, ma <em>ogni 5 ore</em>.</p>
<p style="text-align: left;">Il funzionamento del sito è talmente semplice ed intuitivo che non necessita di alcuna spiegazione. Potete valutare voi di persona, ed in caso di problemi, cercheremo di trovare una soluzione.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/creare-rss-per-tutti-i-siti/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>L&#8217;ADSL in alcune parti non arriverà mai&#8230;</title>
		<link>http://www.nerthase.com/blog/ladsl-in-alcune-parti-non-arrivera-mai?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ladsl-in-alcune-parti-non-arrivera-mai</link>
		<comments>http://www.nerthase.com/blog/ladsl-in-alcune-parti-non-arrivera-mai#comments</comments>
		<pubDate>Sat, 06 Mar 2010 18:56:50 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[ADSL]]></category>
		<category><![CDATA[Anti Digital Divide]]></category>
		<category><![CDATA[Telecom]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=318</guid>
		<description><![CDATA[La telecom ha pubblicato di recente una pagina Web dove poter consultare gli elenchi aggiornati delle zone coperte da ADSL. Questo progetto portato avanti da Telecom da diverso tempo, si chiama Anti Digital Divide. A vederlo così, sembra tutto rose e fiori per gli sfortunati come me ancora non raggiunti da ADSL. Invece, molti dei&#8230;]]></description>
			<content:encoded><![CDATA[<p>La telecom ha pubblicato di recente una <a title="Anti Digital Divide" href="http://www.alice.it/assistenza/anti_digital_divide.html" target="_blank">pagina Web</a> dove poter consultare gli elenchi aggiornati delle zone coperte da ADSL. Questo progetto portato avanti da Telecom da diverso tempo, si chiama <strong>Anti Digital Divide</strong>. <a class="lightbox" style="text-decoration: none;" title="Anti Digital Divide Telecom" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/banner-telecom.png"><img class="aligncenter size-full wp-image-319" title="Anti Digital Divide Telecom" src="http://www.nerthase.com/blog/wp-content/uploads/2010/03/banner-telecom.png" alt="" width="645" height="160" /></a></p>
<p>A vederlo così, sembra tutto rose e fiori per gli sfortunati come me ancora non raggiunti da ADSL. Invece, molti dei comuni del Lazio che sono in lista (parlo per la mia provincia), hanno la copertura ADSL già da diversi anni, e soprattutto, una copertura che è stata fornita al di fuori del progetto <strong>Anti Digital Divide</strong>. Forse hanno pubblicato questo piccolo elenco per accendere le speranze degli <em>&#8220;scoperti&#8221;</em>, o per far credere che stanno lavorando per noi.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
Con pochissima fiducia, ho consultato l&#8217;elenco della mia regione, ed ho visto che il mio comune, ancora non è in lista. Con ancor meno fiducia, ho fatto la verifica di copertura mediante l&#8217;apposito servizio, e mi ha dato lo stesso risultato.</p>
<p><a class="lightbox" style="text-decoration: none;" title="Copertura ADSL" href="http://www.nerthase.com/blog/wp-content/uploads/2010/03/casa-adsl.png"><img class="aligncenter size-full wp-image-320" title="Copertura ADSL" src="http://www.nerthase.com/blog/wp-content/uploads/2010/03/casa-adsl.png" alt="" width="648" height="743" /></a></p>
<p>In attesa di una svolta, visto che anche il WiMax sembra non arrivare mai, continuo a dare i miei 12 euro mensili a Telecom per una 56k più che insoddisfacente.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/ladsl-in-alcune-parti-non-arrivera-mai/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PhotoShop bloccato in &#8220;Reading Preferences&#8221;</title>
		<link>http://www.nerthase.com/blog/photoshop-bloccato-in-reading-preferences?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=photoshop-bloccato-in-reading-preferences</link>
		<comments>http://www.nerthase.com/blog/photoshop-bloccato-in-reading-preferences#comments</comments>
		<pubDate>Sat, 27 Feb 2010 21:58:58 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Errore]]></category>
		<category><![CDATA[PhotoShop]]></category>
		<category><![CDATA[preferenze]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=286</guid>
		<description><![CDATA[Le mie disavventure con la suite di programmi Adobe non avranno mai fine. Dopo l&#8217;errore 150:30 ed i problemi di licenza in DreamWeaver, oggi aprendo PhotoShop CS4, il programma rimane bloccato e non si avvia. PhotoShop rimane bloccato durante l&#8217;avvio, e lo Splash Screen iniziale è fermo durante il passo &#8220;Reading Preferences&#8220;. Non resta che&#8230;]]></description>
			<content:encoded><![CDATA[<p>Le mie disavventure con la suite di programmi Adobe non avranno mai fine. Dopo l&#8217;<a title="Adobe errore 150:30" href="http://www.nerthase.com/blog/adobe-cs4-errore-15030" target="_blank">errore 150:30</a> ed i <a title="Errore 150:30 - problemi di licenza" href="http://www.nerthase.com/blog/adobe-cs4-errore-15030" target="_blank">problemi di licenza in DreamWeaver</a>, oggi aprendo PhotoShop CS4, il programma rimane bloccato e non si avvia. PhotoShop rimane bloccato durante l&#8217;avvio, e lo Splash Screen iniziale è fermo durante il passo &#8220;<strong>Reading Preferences</strong>&#8220;.</p>
<p><a class="lightbox" title="Photoshop - Reading Preferences" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/Photoshop-Reading-Preferences.png"><img class="aligncenter size-full wp-image-288" title="Photoshop - Reading Preferences" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/Photoshop-Reading-Preferences.png" alt="" width="634" height="364" /></a></p>
<p>Non resta che forzare l&#8217;uscita del programma. Questo errore è causato da un errore nella lettura delle preferenze e impostazioni di PhotoShop. La soluzione a questo problema è un po&#8217; drastica, in quanto comporta l&#8217;eliminazione delle preferenze di PhotoShop.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
Per risolvere questo problema dobbiamo individuare sulla tastiera i tasti <strong>CMD</strong>, <strong>ALT</strong> e <strong>SHIFT</strong> (per Windows premere i tasti <strong>CTRL</strong>, <strong>ALT</strong> e <strong>SHIFT</strong>) e tenerli premuti durante il prossimo avvio di PhotoShop. Vi verrà chiesto se volete veramente cancellare le impostazioni. Rispondete <strong>SI</strong> ed avrete il vostro PhotoShop nuovamente funzionante.</p>
<p><a class="lightbox" style="text-decoration: none;" title="Photoshop - Delete Preferences" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/Photoshop-Delete-Preferences.png"><img class="aligncenter size-full wp-image-287" title="Photoshop - Delete Preferences" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/Photoshop-Delete-Preferences.png" alt="" width="442" height="225" /></a></p>
<p>Io personalmente non ho impostazioni di fondamentale importanza in PhotoShop, ma se qualcuno di voi lo usa quotidianamente per lavoro, potrebbe trovare questa soluzione improponibile. Se conoscete una soluzione meno drastica, vi prego di comunicarmela.</p>
<p>Grazie</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/photoshop-bloccato-in-reading-preferences/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jDownloader: RapidShare e MegaUpload senza limiti</title>
		<link>http://www.nerthase.com/blog/jdownloader-rapidshare-e-megaupload-senza-limiti?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=jdownloader-rapidshare-e-megaupload-senza-limiti</link>
		<comments>http://www.nerthase.com/blog/jdownloader-rapidshare-e-megaupload-senza-limiti#comments</comments>
		<pubDate>Sat, 27 Feb 2010 21:14:08 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mondo Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[account premium]]></category>
		<category><![CDATA[CAPTCHA]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[download senza limiti]]></category>
		<category><![CDATA[HotFile]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jDownloader]]></category>
		<category><![CDATA[MegaUpload]]></category>
		<category><![CDATA[MegaVideo]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[RapidShare]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=276</guid>
		<description><![CDATA[jDownloader è un utilissimo programma open source scritto completamente in Java, e quindi compatibile con tutti i sistemi operativi che lo supportano. Il suo scopo è quello di scaricare file da siti come RapidShare e MegaUpload, ma anche tanti altri come loro. jDownloader si occuperà di attendere la disponibilità del download al posto nostro, ed&#8230;]]></description>
			<content:encoded><![CDATA[<p><a title="jDownloader: RapidShare e MegaUpload senza limiti" href="http://jdownloader.org/" target="_blank">jDownloader</a> è un utilissimo programma <strong>open source</strong> scritto completamente in Java, e quindi compatibile con tutti i sistemi operativi che lo supportano. Il suo scopo è quello di scaricare file da siti come RapidShare e MegaUpload, ma anche tanti altri come loro. jDownloader si occuperà di attendere la disponibilità del download al posto nostro, ed effettuerà anche il bypass dei codici CAPTCHA spesso utilizzati da siti del genere.</p>
<p>Ma le novità e le potenzialità di jDownloader non sono finite qui. Esso infatti è in grado di effettuare il download di filmati di YouTube, MegaVideo e quanto altro possiate immaginare. Inoltre ha anche l&#8217;opzione per effettuare i download usufruendo di un account premium in vostro possesso. E se invece non possedete un account premium, jDownloader si occuperà di effettuare un cambio di IP per il vostro computer, in modo da evitare controlli e barriere applicati da alcuni siti di File Sharing.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
Dopo questa breve panoramica per questo meraviglioso software, veniamo ad una breve guida di configurazione ed utilizzo:</p>
<p><a class="lightbox" style="text-decoration: none;" title="jD1" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD1.png"><img class="aligncenter size-full wp-image-278" title="jD1" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD1.png" alt="" width="270" height="334" /></a></p>
<p>Dopo l&#8217;installazione, è necessario settare alcune impostazioni iniziali per l&#8217;utilizzo del software,</p>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="jD2" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD2.png"><img class="aligncenter size-full wp-image-279" title="jD2" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD2.png" alt="" width="575" height="376" /></a></p>
<p>Impostiamo il percorso per i nostri download ed il comportamento che jDownloader dovrà adottare per i file scaricati. Queste semplici impostazioni sono già sufficienti per iniziare ad effettuare il download dei nostri file.</p>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="jD3" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD3.png"><img class="aligncenter size-full wp-image-280" title="jD3" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD3.png" alt="" width="575" height="376" /></a></p>
<p>Come vi dicevo prima, jDownload è in grado di cambiare l&#8217;IP del nostro computer mediante una riconnessione del router. Questa impostazione è molto utile nel caso di siti di File Sharing che effettuano controlli su IP. Basterà individuare il modello del nostro router, selezionare &#8220;<em>Ottieni IP router</em>&#8221; ed infine &#8220;<em>Crea script di riconnessione</em>&#8220;. Automaticamente jDownloader creerà uno script ad hoc per il nostro router in grado di effettuare una riconnessione, e quindi il cambio di IP.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div></p>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="jD4" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD4.png"><img class="aligncenter size-full wp-image-281" title="jD4" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD4.png" alt="" width="575" height="376" /></a></p>
<p>Per chi di noi possiede un <strong>account premium</strong>, può usarlo tramite jDownloader per scaricare al massimo della velocità con il massimo della comodità. Sono supportati più di 100 servizi di Hosting.</p>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="jD5" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD5.png"><img class="aligncenter size-full wp-image-282" title="jD5" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD5.png" alt="" width="575" height="376" /></a></p>
<p>jDownloader ha la possibilità di intercettare il contenuto degli <em>appunti di sistema</em>. In pratica ci basterà individuare su internet l&#8217;elenco dei link del file che vogliamo scaricare, copiarli e spostarci su jDownloader. Il programma avrà già intercettato i nostri appunti, e sarà in corso l&#8217;analisi dei link. Se al termine dell&#8217;analisi i file che si desidera scaricare sono tutti online, basterà premere il tasto &#8220;<em>Continua</em>&#8221; per iniziare il download.</p>
<p style="text-align: center;"><a class="lightbox" style="text-decoration: none;" title="jD6" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD6.png"><img class="aligncenter size-full wp-image-283" title="jD6" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/jD6.png" alt="" width="575" height="376" /></a></p>
<p>jDownloader è in grado di estrarre i file una volta scaricati, anche se protetti da password, e di unirli in un unico file, come da origine. Voi non dovrete fare assolutamente nulla.</p>
<p>. . .</p>
<p>jDownloader è un software molto completo e funzionale. Lo sviluppatore rilascia continui aggiornamenti, che ne garantiscono il funzionamento continuo. Adesso vi lascio alcuni link per il download del programma e delle dipendenze necessarie:</p>
<ul>
<li><a title="jDownloader downloads" href="http://jdownloader.org/download/index" target="_blank">jDownloader</a></li>
<li><a title="Java" href="http://www.java.com/en/download/manual.jsp" target="_blank">Java</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/jdownloader-rapidshare-e-megaupload-senza-limiti/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Generatore di Password</title>
		<link>http://www.nerthase.com/blog/generatore-di-password?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=generatore-di-password</link>
		<comments>http://www.nerthase.com/blog/generatore-di-password#comments</comments>
		<pubDate>Sat, 27 Feb 2010 00:09:13 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Guide]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mondo Linux]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[cracker]]></category>
		<category><![CDATA[generare password]]></category>
		<category><![CDATA[generator]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[Mnemonic]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[sicurezza]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=246</guid>
		<description><![CDATA[Dopo aver visto come creare una password sicura, e come evitare di farsi rubare la propria password, non poteva mancare un programma per la generazione di password robuste, ma allo stesso tempo facili da ricordare. Il programma da me realizzato, si chiama Mnemonic Password Generator, e ha lo scopo di generare una password diversa per&#8230;]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Dopo aver visto come <a title="Creare password" href="http://www.nerthase.com/blog/password-come-evitare-il-crack" target="_blank">creare una password sicura</a>, e come evitare di farsi <a title="rubare password" href="http://www.nerthase.com/blog/password-come-evitare-il-crack" target="_blank">rubare la propria password</a>, non poteva mancare un programma per la generazione di password robuste, ma allo stesso tempo facili da ricordare.</p>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<p style="text-align: justify;">Il programma da me realizzato, si chiama<strong> Mnemonic Password Generator</strong>, e ha lo scopo di generare una password diversa per ogni servizio che voi utilizzate. Questa password inoltre, sarà basata su vostri dati personali, e quindi facile da ricordare. Ad esempio, basterà dire al programma che io mi chiamo <strong>Mario</strong>, nato a <strong>Settembre</strong>, e che voglio una password per <a title="nerthase" href="http://twitter.com/nerthase" target="_blank">Twitter</a>, ed una possibile password che il programma mi proporrà, potrebbe essere <strong>mario09twitter</strong>. Come potete vedere questa password è molto facile da ricordare, ma ha tutti gli elementi necessari per durare a lungo contro attacchi di hacker, cracker e malintenzionati.</p>
<p style="text-align: center;"><a class="lightbox" title="Mnemonic Password Generator" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/mpg-screen.png"><img class="aligncenter size-full wp-image-247" title="Mnemonic Password Generator" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/mpg-screen.png" alt="" width="573" height="318" /></a></p>
<p style="text-align: justify;">Mnemonic Password Generator è stato realizzato in Java ed offre tutte i controlli necessari a personalizzare la propria password preferendo facilità o sicurezza. Il programma non fa alcun uso delle password generate e/o dei dati inseriti. Questi ultimi sono richiesti al solo scopo di generare una password che sia adatta a voi, e quindi facile da ricordare. MPG (sigla del programma) memorizza i dati da voi inseriti (ma non la password) in un file temporaneo sul vostro computer. L&#8217;unico scopo di questo salvataggio, è di evitarvi di riempire tutti i campi ogni volta. Potete, comunque, in qualunque momento eliminare il file contenente questi dati.</p>
<p style="text-align: justify;">Il programma Mnemonic Password Generator è disponibile per il download per diverse piattaforme:</p>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<table style="text-align: justify; border: 0px solid #ffffff;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><a class="lightbox" title="windows" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/windows.png"><img class="aligncenter size-full wp-image-251" title="windows" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/windows.png" alt="" width="58" height="58" /></a></td>
<td>
<p style="text-align: left;"><a title="Mnemonic Password Generator - Windows XP Vista Seven" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/MnemonicPasswordGenerator.exe.zip" target="_blank">Mnemonic Password Generator compatibile con Windows XP / Vista / Seven</a></p>
<p>Non necessita di installazione. Applicazione portabile.</td>
</tr>
<tr>
<td>
<p style="text-align: center;"><a class="lightbox" title="Icona Finder" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/mac.png"><img class="size-full wp-image-249 aligncenter" title="Icona Finder" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/mac.png" alt="Icona Finder" width="58" height="58" /></a></p>
</td>
<td><a title="Mnemonic Password Generator - Mac OS X" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/MnemonicPasswordGenerator.zip" target="_blank">Mnemonic Password Generator compatibile con Mac OS X v10.5 e successive</a></p>
<p>Versione sviluppata su piattaforma Mac OS X 10.6 e quindi pienamente compatibile.</td>
</tr>
<tr>
<td><a class="lightbox" title="universal" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/universal.png"><img class="aligncenter size-full wp-image-250" title="universal" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/universal.png" alt="" width="48" height="58" /></a></td>
<td><a title="Mnemonic Password Generator - Universal Binary" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/MnemonicPasswordGenerator.jar.zip" target="_blank">Mnemonic Password Generator compatibile con Linux ed altre piattaforme</a></p>
<p>Versione Universal Binary dell&#8217;applicazione. Funziona su qualsiasi sistema.</td>
</tr>
</tbody>
</table>
<p style="text-align: justify;">Per malfunzionamenti o problemi di vario genere, sono a vostra completa disposizione.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/generatore-di-password/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password: come evitare il Crack</title>
		<link>http://www.nerthase.com/blog/password-come-evitare-il-crack?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=password-come-evitare-il-crack</link>
		<comments>http://www.nerthase.com/blog/password-come-evitare-il-crack#comments</comments>
		<pubDate>Fri, 26 Feb 2010 00:33:46 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Informatica & co]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[attacco dizionario]]></category>
		<category><![CDATA[brute force]]></category>
		<category><![CDATA[crack]]></category>
		<category><![CDATA[cracker]]></category>
		<category><![CDATA[ddos]]></category>
		<category><![CDATA[Hack]]></category>
		<category><![CDATA[hacker]]></category>
		<category><![CDATA[Password]]></category>
		<category><![CDATA[phishing]]></category>
		<category><![CDATA[scoprire password]]></category>
		<category><![CDATA[sicurezza]]></category>
		<category><![CDATA[trojan]]></category>
		<category><![CDATA[virus]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=231</guid>
		<description><![CDATA[Dopo avervi parlato del Brute Force, delle sue applicazioni e avervi rilasciato un esempio di codice Java che lo implementa, vi voglio parlare delle PASSWORD, della loro importanza, e soprattutto dell&#8217;attenzione che bisogna avere al momento di sceglierne una. Analizziamo prima alcuni dati fondamentali: Con un semplice programma Java, un tentativo di login presso un&#8230;]]></description>
			<content:encoded><![CDATA[<p>Dopo avervi parlato del <a title="Brute Force per crackare una password" href="http://www.nerthase.com/blog/brute-force-in-java" target="_blank">Brute Force</a>, delle sue applicazioni e avervi rilasciato un esempio di <a title="Brute Force in Java" href="http://www.nerthase.com/blog/brute-force-in-java" target="_blank">codice Java</a> che lo implementa, vi voglio parlare delle <strong>PASSWORD</strong>, della loro importanza, e soprattutto dell&#8217;attenzione che bisogna avere al momento di sceglierne una.</p>
<p>Analizziamo prima alcuni dati fondamentali:</p>
<ul>
<li>Con un semplice programma Java, <em>un tentativo di login presso un sito richiede meno di un secondo</em>;</li>
<li><em>La lunghezza media delle password</em> più usate è di 6 caratteri (il minimo che forum come phpBB permettono);</li>
<li>Se nella password di 6 caratteri sono usati solo numeri (data di nascita) i casi possibili sono 10<sup>6</sup> = 1000000;</li>
<li>Se nella password di 6 caratteri sono usate solo lettere, i casi possibili sono 21<sup>6 </sup>= 85766121;</li>
<li>Se la password è una parola italiana di senso compiuto, abbiamo questi valori relativi alla lunghezza:
<ul>
<li>Parole italiane di 6 caratteri: 13545</li>
<li>Parole italiane di 7 caratteri: 25802</li>
<li>Parole italiane di 8 caratteri: 35409</li>
<li>Parole italiane di 9 caratteri: 46069</li>
<li>Parole italiane di 10 caratteri: 47932</li>
</ul>
</li>
</ul>
<p>Detto questo, i conti sono presto fatti. Un possibile malintenzionato, sicuramente partirebbe a tentare le password che richiedono il minor numero di tentativi:<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div></p>
<h4>Attacco a dizionario</h4>
<p>Questo tipo di attacco, è uno dei più semplici ma anche dei più riusciti. Se non vi sembra possibile, provate a ricordare, se avete mai pensato di inserire come password il nome di un vostro animale preferito, della vostra ragazza, della vostra auto preferita, e molto altro ancora&#8230; Tutte queste parole in genere sono presenti nel dizionario italiano, o in alcuni dizionari che Hacker o Cracker si costruiscono arricchendo il dizionario italiano, con parole aggiuntive, che potrebbero essere usate come password.</p>
<p>Facendo due rapidi calcoli, l&#8217;attaccante impiegherebbe:</p>
<ul>
<li>Password di 6 caratteri: <strong>13545 tentativi</strong> x <strong>1 secondo</strong> = <strong>13545 secondi</strong> = <strong>quasi 4 ore</strong></li>
<li>Password di 7 caratteri:<strong> <strong>25802 tentativi</strong> x <strong>1 secondo</strong> = 25802 <strong>secondi</strong> = <strong>quasi 8 ore</strong></strong></li>
<li><span style="font-weight: 800;">.  .  .</span></li>
</ul>
<p>Vediamo subito che in un giorno, la nostra password potrebbe essere facilmente violata. Per questo è sempre consigliabile adottare password che non sono presenti in un dizionario, o combinare due parole di senso compiuto, o alternare parole e numeri. In pratica allungare la password, e spaziare tra caratteri e numeri.</p>
<h4>Attacco a Forza Bruta (<a title="Brute Force in Java" href="http://www.nerthase.com/blog/brute-force-in-java" target="_blank">Brute Force</a>)</h4>
<p>Questo tipo di attacco, sicuramente è conosciuto da tutti, se non altro per il <a title="Brute Force in Java" href="http://www.nerthase.com/blog/brute-force-in-java" target="_blank">mio precedente articolo</a>. In questo caso l&#8217;attaccante proverà inizialmente password numeriche, perché come ben sapete, molti di noi ancora usano come password la propria data di nascita. Purtroppo proprio queste password, sono quelle che vengono violate più spesso, non da attaccanti esterni, ma da conoscenti che si divertono ad incasinare la vita altrui.</p>
<p>Comunque, un possibile attaccante questa volta impiegherebbe:</p>
<ul>
<li>Password di 6 caratteri composta da soli numeri: <strong>10</strong><sup><strong>6</strong></sup> <strong>tentativi </strong>x <strong>1 secondo</strong> = <strong>più di 10 giorni</strong></li>
<li>Password di 6 caratteri composta da sole lettere:<strong> <strong>21</strong><sup><strong>6</strong></sup> <strong>tentativi</strong><span style="font-weight: normal;"> x </span><strong>1 secondo</strong> = <strong>più di 2 anni</strong></strong></li>
</ul>
<p>Questi valori così elevati non devono affatto rassicurarvi, perché come vedremo più avanti, l&#8217;ipotesi di impiegare un secondo per tentare una password, è si realistica, ma molto obsoleta.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div></p>
<h4>Phishing</h4>
<p>Questo tipo di attacco, è uno dei più subdoli che possa esistere. Basato sull&#8217;Ingegneria Sociale, trae l&#8217;utente in inganno, in modo che sia egli stesso a fornire la password all&#8217;attaccante. Ormai si sentono notizie tutti i giorni su persone cadute in un attacco del genere. Il problema più grande, è generato dal fatto che questo attacco è semplicissimo da applicare, e che le persone non prestano mai attenzione quando forniscono i propri dati personali.</p>
<p>Il phishing in pratica consiste nel creare una falsa pagina di login (ad esempio una copia esatta della pagina di login del sito delle poste) e fornirla agli utenti in svariati modi (e-mail, forum, newsletter etc&#8230;). L&#8217;utente, ad esempio, riceve una e-mail in cui gli viene gentilmente chiesto di controllare periodicamente il suo conto Banco Posta presso il link fornito (che non punterà al sito delle Poste Italiane, ma bensì alla falsa pagina di login creata dall&#8217;attaccante). L&#8217;utente, riconoscendo visivamente la pagina di login, inserirà senza problemi i propri dati personali. Ed è qui, che ha perso tutto quello che possedeva.</p>
<p>Per evitare questo tipo di attaccho, basta prestare attenzione ai link che si visitano, e soprattutto all&#8217;URL della pagina nella quale forniamo i nostri dati. Verifichiamo che sia sempre la giusta pagina, e possibilmente, che usi il protocollo <strong>https</strong>.</p>
<h4>Attacco distribuito</h4>
<p>Questo non è un vero e proprio attacco, ma è un&#8217;evoluzione dei primi due attacchi che abbiamo visto. Infatti, per ridurre i tempi per portare a segno un attacco, non si usa un solo computer, ma se ne usano diversi, dividendosi i compiti. Se avete letto il mio recente articolo sul <a title="Calcolo distribuito per risolvere un Puzzle" href="http://www.nerthase.com/blog/puzzle-risolto-con-lelaborazione-distribuita" target="_blank">Puzzle Distribuito</a> sapete di sicuro di cosa vi sto parlando.</p>
<p>In pratica, con un attacco a dizionario per parole di 6 lettere, usando un solo computer, venivano impiegate 4 ore. Se lo stesso attacco, fosse portato a compimento usando 4 computer, e dividendosi equamente le 13545 parole di 6 lettere,<em> impiegherebbe solamente un&#8217;ora</em>. Usando ancora più computer, questo attacco potrebbe impiegare pochi minuti. Un miglioramento di prestazioni elevato però, potrà essere quantificabile solo se il numero dei computer coinvolti è molto elevato. Pensate che un attacco a Forza Bruta usando <em>caratteri e numeri</em> potrebbe essere compiuto in meno di un giorno, invece dei 2 anni precedentemente calcolati.</p>
<p>Se vi state domandando come possano, eventuali Hacker o Cracker avere a disposizione una simile potenza di calcolo, vi dico un solo termine: <strong>Trojan</strong>. Sicuramente nella vostra vita, avete ricevuto almeno un allarme dall&#8217;antivirus, in cui vi veniva notificata la presenza di un Trojan all&#8217;interno del vostro computer. I Trojan non sono veri e propri virus che infettano e/o compromettono il vostro computer. Bensì sono dei <em>cavalli di Troia</em> che possono eseguire all&#8217;interno del vostro computer operazioni senza il vostro consenso. Spesso questi Trojan infettano milioni di computer restando apparentemente innocui per un lungo periodo di tempo. Infatti, è dopo aver infettato il giusto numero di macchine, che questi Trojan entrano in azioni, comandati da un Server centrale. Il Server comunicherà quindi ai Trojan il sito bersaglio, dividerà le possibili password tra i vari computer infettati, e l&#8217;attacco sarà compiuto in un batter d&#8217;occhio. Se ci pensate bene, è lo stesso sistema che ho usato io nella realizzazione del <a title="Calcolo distribuito per risolvere un Puzzle" href="http://www.nerthase.com/blog/?p=226" target="_blank">Puzzle Distribuito</a>. Un semplice e banale sistema, che però può compromettere la sicurezza di intere strutture, in un tempo brevissimo.</p>
<p>Dopo essermi tanto dilungato, concluderei semplicemente con il consigliarvi di utilizzare password abbastanza robuste, che non siano individuabili con un semplice attacco a dizionario o Brute Force usando solo lettere o numeri. Usate sempre lettere <strong>E</strong> numeri, e perché no, anche qualche carattere speciale. Tanto i tasti della tastiera li abbiamo pagati tutti, quindi perché non usare anche il simbolo <strong>§</strong> che altrimenti non sappiamo mai dove mettere?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/password-come-evitare-il-crack/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Google, YouTube, Wikipedia insieme in People Finder</title>
		<link>http://www.nerthase.com/blog/google-youtube-wikipedia-in-people-finder?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-youtube-wikipedia-in-people-finder</link>
		<comments>http://www.nerthase.com/blog/google-youtube-wikipedia-in-people-finder#comments</comments>
		<pubDate>Tue, 23 Feb 2010 16:11:24 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Guide]]></category>
		<category><![CDATA[HTML & CSS]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[Angelina Jolie]]></category>
		<category><![CDATA[Beyoncé]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Michelle Hunziker]]></category>
		<category><![CDATA[Motore di ricerca]]></category>
		<category><![CDATA[people finder]]></category>
		<category><![CDATA[personaggi famosi]]></category>
		<category><![CDATA[toutube]]></category>
		<category><![CDATA[VIP]]></category>
		<category><![CDATA[wikipedia]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=210</guid>
		<description><![CDATA[Oggi voglio condividere con voi il progetto che ho realizzato con alcuni compagni di Università qualche tempo fa. People Finder, questo è il nome del progetto, nasce dall&#8217;esigenza di molti di avere a disposizioni informazioni di diverso genere a natura, tutto su un&#8217;unica pagina Web. People Finder realizza proprio questo. People Finder permette di effettuare&#8230;]]></description>
			<content:encoded><![CDATA[<p>Oggi voglio condividere con voi il progetto che ho realizzato con alcuni compagni di Università qualche tempo fa. <strong>People Finder</strong>, questo è il nome del progetto, nasce dall&#8217;esigenza di molti di avere a disposizioni informazioni di diverso genere a natura, tutto su un&#8217;unica pagina Web.</p>
<p><a class="lightbox" title="People Finder" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/People-Finder.png"><img class="aligncenter size-full wp-image-211" title="People Finder" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/People-Finder.png" alt="" width="500" height="83" /></a></p>
<p>People Finder realizza proprio questo. People Finder permette di effettuare ricerche su personaggi famosi (ma potete spaziare su qualsiasi genere vogliate), e restituisce i risultati della ricerca, interrogando a sua volta Google Immagini, YouTube e Wikipedia. Come potete vedere dall&#8217;immagine seguente, tutte le informazioni vengono visualizzate in una singola pagina, e messe così a completa disposizione dell&#8217;utente finale. In particolare, in People Finder, potrete <em>navigare</em> tra le prima 16 immagini restituite da Google inerenti al personaggio desiderato, o tra 4 video dello stesso, ognuno avente un diverso criterio di valutazione, <em><strong>il tutto effettuando una sola ricerca, e su una sola pagina</strong></em>.</p>
<p style="text-align: center;"><a class="lightbox" title="People Finder" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/People-Finder-screen.png"><img class="aligncenter size-full wp-image-212" title="People Finder" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/People-Finder-screen.png" alt="" width="622" height="389" /></a></p>
<p>People Finder è stato realizzato in <strong>Java</strong> ed usa diverse librerie esterne per la gestione di Google, YouTube ed altro ancora. Per essere reso disponibile a tutti gli utenti, senza necessità di software di installazione, è stato sviluppato con tecnologia Web, e quindi il fulcro di People Finder è proprio la pagina JSP che si visualizza al momento della ricerca.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
Come potete vedere nel video seguente, la navigazione tra le immagini ed i video è veramente immediata ed intuitiva. Inoltre viene messa in risalto la descrizione iniziale che Wikipedia offre del personaggio cercato. Nel resto della pagina, viene riportato il contenuto della pagina di Wikipedia, ovviamente ripulita e riorganizzata. People Finder è stato progettato e realizzato avendo cura di occupare il minor numero di risorse possibile, soprattutto per quanto riguarda la banda a disposizione.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/7UB1OnOOSZE&amp;hl=it_IT&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/7UB1OnOOSZE&amp;hl=it_IT&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>Ma non è finita qui. <strong>People Finder può essere usato anche senza una connessione internet</strong>. Infatti è disponibile un piccolo applicativo da poter usare sul proprio computer, che permette di effettuare ricerche, di qualsiasi genere, e fornire i risultati interrogando la <em>base documentale</em> precostruita. Questa base documentale può essere completamente personalizzata, arricchita e adattata alle proprie esigenze. Quando si effettuano modifiche alla base documentale, c&#8217;è bisogno di ricostruirla per poter poi essere di nuovo utilizzata. Questo è l&#8217;unico momento in cui è necessaria una connessione internet.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div><br />
I documenti all&#8217;interno della base documentale, vengono prelevati direttamente dal Web, utilizzando il portale di People Finder, ma questa volta limitandosi ai soli risultati di Wikipedia. Una volta collezionati questi documenti, vengono indicizzati esattamente nello stesso modo utilizzato da Google, ma con algoritmi diversi. Sarà quindi possibile effettuare ricerche libere, senza essere vincolati a ricercare esattamente il personaggio desiderato. L&#8217;utilizzo del software è mostrato nel seguente video.</p>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/nrj2BTwXKDM&amp;hl=it_IT&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/nrj2BTwXKDM&amp;hl=it_IT&amp;fs=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>People Finder è stato realizzato come progetto universitario, ma come potete vedere ha tutte le caratteristiche e potenzialità per essere usato e distribuito nel mondo reale. Avere una <em>galleria di immagini</em>, una <em>galleria di video</em> e la descrizione accurata e controllata di Wikipedia come risultato della ricerca, il tutto in una sola pagina, è per molti ancora un&#8217;utopia, che costringe ad effettuare più volte la stessa ricerca, per ottenere risultati di natura diversa, offerti da portali diversi.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/google-youtube-wikipedia-in-people-finder/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Rubik&#8217;s 360</title>
		<link>http://www.nerthase.com/blog/rubiks-360?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=rubiks-360</link>
		<comments>http://www.nerthase.com/blog/rubiks-360#comments</comments>
		<pubDate>Tue, 23 Feb 2010 13:24:03 +0000</pubDate>
		<dc:creator>nerthase</dc:creator>
				<category><![CDATA[Tutto il resto]]></category>
		<category><![CDATA[Cubo di Rubik]]></category>
		<category><![CDATA[giochi d'ingegno]]></category>
		<category><![CDATA[rompicapo]]></category>
		<category><![CDATA[Rubik's 360]]></category>

		<guid isPermaLink="false">http://www.nerthase.com/blog/?p=201</guid>
		<description><![CDATA[Sono sempre stato un appassionato dei giochi d&#8217;ingegno e per i rompicapo in generale, e tra questi, non poteva di certo mancare il famosissimo Cubo di Rubik. Ma da un po&#8217; di tempo, Rubik, ha tirato fuori il suo nuovo rompicapo, chiamato Rubik&#8217;s 360. A differenza dei precedenti, non si presenta come un cubo, ma&#8230;]]></description>
			<content:encoded><![CDATA[<p>Sono sempre stato un appassionato dei giochi d&#8217;ingegno e per i rompicapo in generale, e tra questi, non poteva di certo mancare il famosissimo <strong>Cubo di Rubik</strong>. Ma da un po&#8217; di tempo, Rubik, ha tirato fuori il suo nuovo rompicapo, chiamato <strong>Rubik&#8217;s 360</strong>. A differenza dei precedenti, non si presenta come un cubo, ma come una sfera, da cui il nome &#8220;360&#8243;. Scopo di questo rompicapo non è dunque quello di allineare dei cubetti, ma di portare sei palline (i colori sono gli stessi delle facce dei cubi delle altre edizioni) nelle sezioni esterne della sfera.<br />
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div></p>
<p><strong>Com&#8217;è fatto il Rubik&#8217;s 360:</strong></p>
<p>Questo rompicapo è costituito da tre sfere concentriche:</p>
<ul>
<li>la prima sfera presenta un foro e contiene, nella posizione iniziale, le sei palline. Queste possono passare attraverso il foro per raggiungere la seconda sfera</li>
<li>la seconda sfera possiede due fori, ciascuno dei quali permette alle palline di raggiungere le sezioni esterne di un emisfero della terza sfera</li>
<li>la terza sfera possiede sei sezioni esterne, abbinate dal colore alle palline, e due sezioni rotanti nere che permettono di intrappolare le palline che hanno raggiunto la loro destinazione.</li>
</ul>
<p>Ciò che rende complicata la risoluzione del gioco è la presenza di alcuni contrappesi nelle prime due sfere che mantengono i fori al di sopra dell&#8217;asse di rotazione. È necessario capire in che modo essi agiscano per consentire alle palline di vincere la forza di gravità e proseguire verso le sezioni esterne. Per questo rompicapo, dunque, non esistono calcoli combinatori per studiare la disposizione delle palline.</p>
<p>Dopo questa breve spiegazione sulla struttura e sui segreti del Rubik&#8217;s 360, vi faccio vedere come si presenta una volta risolto. Risolvere questo rompicapo è molto più semplice che risolvere il Cubo di Rubik. Quando si ha in mano il Rubik&#8217;s 360, basterà ruotarlo con calma, e dopo alcuni tentativi, si capisce immediatamente il segreto per <em>invertire la gravità</em> all&#8217;interno della sfera. Infatti, tutto il segreto sta nel fare in modo che i buchi delle sfere interne vadano in basso, in modo da permettere alle palline di fuoriuscire.</p>
<p style="text-align: center;"><a class="lightbox" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik1.jpg"><img class="size-full wp-image-202 aligncenter" title="Rubik's 360" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik1.jpg" alt="" width="600" height="542" /></a></p>
<p style="text-align: center;"><a class="lightbox" title="Rubik's 360" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik2.jpg"><img class="aligncenter size-full wp-image-203" title="Rubik's 360" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik2.jpg" alt="" width="600" height="200" /></a></p>
<div class="clear-block"><div class="ad alignleft"><script type="text/javascript"><!--
google_ad_client = "ca-pub-3082594121433544";
/* 728x90, creato 30/07/09 */
google_ad_slot = "9645358027";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div></div>
<p style="text-align: center;"><a class="lightbox" title="Rubik's 360" href="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik3.jpg"><img class="aligncenter size-full wp-image-204" title="Rubik's 360" src="http://www.nerthase.com/blog/wp-content/uploads/2010/02/rubik3.jpg" alt="" width="600" height="266" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nerthase.com/blog/rubiks-360/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

