<?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; Mondo Linux</title>
	<atom:link href="http://www.nerthase.com/blog/category/informatica-co/mondo-linux/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>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>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>
	</channel>
</rss>

