add: strdup

This commit is contained in:
2024-09-03 10:37:12 +02:00
parent 3632b34e40
commit b3a4690a85
2 changed files with 29 additions and 1 deletions

27
src/ft_strdup.asm Normal file
View File

@ -0,0 +1,27 @@
extern ft_strlen
extern malloc
extern ft_strcpy
section .text
global ft_strdup
ft_strdup:
call ft_strlen
mov rbx, rdi
mov rdi, rax
call malloc
cmp rax, 0
je error
mov rdi, rax
mov rsi, rbx
call ft_strcpy
ret
error:
xor rax, rax
ret