copy on git

This commit is contained in:
Thomas Rieg 2025-11-28 19:50:58 +01:00
commit 42653de246
205 changed files with 7459 additions and 0 deletions

35
srcs/ft_malloc.c Normal file
View file

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_malloc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thrieg < thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/17 15:02:55 by thrieg #+# #+# */
/* Updated: 2025/11/25 14:30:44 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
#include "../includes/ft_malloc.h"
void *malloc(size_t size)
{
pthread_mutex_lock(&g_mut);
if (!size || size % ALLIGN_BYTES)
size = ((size / ALLIGN_BYTES) + 1) * ALLIGN_BYTES;
void *ret = NULL;
if (size > SMALL_SIZE_MAX)
{
ret = add_large(size);
}
else if (size > TINY_SIZE_MAX)
{
ret = add_small(size);
}
else
{
ret = add_tiny(size);
}
pthread_mutex_unlock(&g_mut);
return (ret);
}