<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alessio Fiorito</title>
    <description>The latest articles on DEV Community by Alessio Fiorito (@fioritoalessio).</description>
    <link>https://dev.to/fioritoalessio</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3795618%2F7cf97bdc-bbbb-4718-a19f-be90b699b500.png</url>
      <title>DEV Community: Alessio Fiorito</title>
      <link>https://dev.to/fioritoalessio</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fioritoalessio"/>
    <language>en</language>
    <item>
      <title>My own memory allocator : a thread-safe, efficient implementation of malloc, calloc, realloc and free - review welcome</title>
      <dc:creator>Alessio Fiorito</dc:creator>
      <pubDate>Thu, 26 Feb 2026 23:52:54 +0000</pubDate>
      <link>https://dev.to/fioritoalessio/my-own-memory-allocator-a-thread-safe-efficient-implementation-of-malloc-calloc-realloc-and-c4o</link>
      <guid>https://dev.to/fioritoalessio/my-own-memory-allocator-a-thread-safe-efficient-implementation-of-malloc-calloc-realloc-and-c4o</guid>
      <description>&lt;p&gt;Hey everyone,&lt;/p&gt;

&lt;p&gt;I decided to code my own memory allocator from scratch as a shared library I can actually use in my other projects. I thought it would be a cool way to understand what happens under the hood of malloc, calloc, realloc and free and build a reusable tool in the process.&lt;/p&gt;

&lt;p&gt;I tried my best to create an efficient, POSIX-compliant, and thread-safe library. Here is what i use&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Direct kernel mapping (mmap / munmap)&lt;/li&gt;
&lt;li&gt;Segregated free lists (O(1) search time)&lt;/li&gt;
&lt;li&gt;Boundary tags (header and footer) with O(1) coalescing&lt;/li&gt;
&lt;li&gt;Anonymous unions and structs inside the header for zero-overhead payloads&lt;/li&gt;
&lt;li&gt;Bitmasking to pack metadata into a single variable and not waste space&lt;/li&gt;
&lt;li&gt;POSIX Mutexes for thread safety&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I tried to think through the architecture by myself as much as possible. Since I mostly code solo projects for now, this is the first time I'm putting my code out there for people to actually see.&lt;/p&gt;

&lt;p&gt;If you have the time and motivation, I would greatly appreciate it if you could check out my GitHub repo and let me know thoughts on the code.&lt;/p&gt;

&lt;p&gt;github repo : &lt;a href="https://github.com/Fiorito-Alessio/af_memory" rel="noopener noreferrer"&gt;https://github.com/Fiorito-Alessio/af_memory&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>c</category>
      <category>programming</category>
      <category>codereview</category>
    </item>
  </channel>
</rss>
