bozo
This commit is contained in:
14
ft_strdup.s
14
ft_strdup.s
@@ -5,18 +5,18 @@ extern ft_strcpy
|
||||
extern malloc
|
||||
|
||||
ft_strdup:
|
||||
call ft_strlen
|
||||
inc rax
|
||||
push rdi
|
||||
call ft_strlen
|
||||
inc rax ; we add one to the result of strlen for the \0
|
||||
push rdi ; we put rdi in r10 for later use
|
||||
mov rdi, rax ; move the result of strlen in rdi
|
||||
call malloc wrt ..plt
|
||||
test rax, rax
|
||||
call malloc wrt ..plt ;
|
||||
test rax, rax ; test if malloc failled
|
||||
je .end
|
||||
pop rsi
|
||||
pop rsi ; we take the value we saved earlier
|
||||
mov rdi, rax ; move the result of malloc into rdi (override strlen result)
|
||||
call ft_strcpy
|
||||
ret
|
||||
|
||||
.end:
|
||||
pop r8
|
||||
pop rsi
|
||||
ret
|
||||
Reference in New Issue
Block a user