Fix issues in mandatory

This commit is contained in:
Xamora 2026-09-20 03:10:41 +02:00
parent 4ef28d1ce9
commit 510ab19fd2
3 changed files with 4 additions and 15 deletions

6
main.c
View file

@ -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);
}

View file

@ -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

View file

@ -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