Fix issues in mandatory
This commit is contained in:
parent
4ef28d1ce9
commit
510ab19fd2
6
main.c
6
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue