From b5172551b8c53ed6085e4ffc65b6bf2f87eca76b Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 17 Jan 2026 18:23:33 +0100 Subject: [PATCH] refactor(strdup): only one exit can change to .exit .restore_exit => .exit --- src/ft_strdup.s | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ft_strdup.s b/src/ft_strdup.s index 7b57390..2bd7fa4 100644 --- a/src/ft_strdup.s +++ b/src/ft_strdup.s @@ -10,18 +10,18 @@ section .text ft_strdup: push rbx ; save rbx cmp rdi, 0 ; check s is NULL - je .restore_exit ; exit (with restore of rbx) if true + je .exit ; exit (with restore of rbx) if true mov rbx, rdi ; save rdi value in rbx call ft_strlen ; call ft_strlen on rdi lea rdi, [rax + 1] ; calculation of the malloc size call malloc ; malloc is called return value on rax test rax, rax ; check the return value of malloc - je .restore_exit ; exit (with restore of rbx) if true + je .exit ; exit (with restore of rbx) if true mov rdi, rax ; set the dest string (for ft_strcpy) mov rsi, rbx ; set the source string (for ft_strcpy) pop rbx ; restore rbx jmp ft_strcpy ; call ft_strcpy -.restore_exit: +.exit: pop rbx ; restore rbx ret ; return rax (NULL)