Fixed a lot of segfaults and bad practices

This commit is contained in:
2024-03-18 10:12:30 +01:00
parent c8170cfd3e
commit ddabaeba7f
10 changed files with 146 additions and 15 deletions

25
ft_strdup.s Normal file
View File

@@ -0,0 +1,25 @@
global ft_strdup
extern ft_strlen
extern ft_strcpy
extern malloc
extern __errno_location
ft_strdup:
cmp rdi, 0
je .end
mov r12, rdi
call ft_strlen
inc rax
mov rdi, rax
call malloc wrt ..plt
test rax, rax
je .end
mov rdi, rax
mov rsi, r12
call ft_strcpy
ret
.end:
xor rax, rax
ret