From 510ab19fd26ca029b348f8e7b75caa425b0dcc0f Mon Sep 17 00:00:00 2001 From: Xamora Date: Sun, 20 Sep 2026 03:10:41 +0200 Subject: [PATCH] Fix issues in mandatory --- main.c | 6 ++++-- src/{calloc.s => ft_calloc.s} | 9 --------- src/ft_strcpy.s | 4 ---- 3 files changed, 4 insertions(+), 15 deletions(-) rename src/{calloc.s => ft_calloc.s} (69%) diff --git a/main.c b/main.c index 78fe5ac..7624abe 100644 --- a/main.c +++ b/main.c @@ -183,12 +183,13 @@ test_calloc() { printf("error: %p\n", error); char *empty = ft_calloc(0, 0); - printf("empty: %s_%p\n", empty, empty); + printf("empty: %p\n", empty); char *buf = ft_calloc(10, 1); strcpy(buf, "test"); printf("test: %s_%p\n", buf, buf); + free(error); free(empty); free(buf); } @@ -203,12 +204,13 @@ test_calloc() { printf("error: %p\n", error); char *empty = calloc(0, 0); - printf("empty: %s_%p\n", empty, empty); + printf("empty: %p\n", empty); char *buf = calloc(10, 1); strcpy(buf, "test"); printf("test: %s_%p\n", buf, buf); + free(error); free(empty); free(buf); } diff --git a/src/calloc.s b/src/ft_calloc.s similarity index 69% rename from src/calloc.s rename to src/ft_calloc.s index f5b65b3..958f917 100644 --- a/src/calloc.s +++ b/src/ft_calloc.s @@ -9,22 +9,13 @@ section .text push rbx mov rbx, rdi - mul rbx, rsi - cmp rbx, rdi - jl return_null - mov rdi, rbx call malloc wrt ..plt mov rdi, rax - inc rbx mov rsi, rbx call bzero wrt ..plt pop rbx ret - return_null: - pop rbx - mov rax, 0 - ret diff --git a/src/ft_strcpy.s b/src/ft_strcpy.s index de6ba00..4740275 100644 --- a/src/ft_strcpy.s +++ b/src/ft_strcpy.s @@ -6,8 +6,6 @@ section .text global ft_strcpy ; rdi = dst, rsi = src ft_strcpy: -; push rbp - mov rax, 0 ; counter mov rcx, 0 mov rdx, 0 @@ -21,7 +19,5 @@ section .text cmp dl, 0 jne loop -; pop rbp - mov rax, rdi ret