diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-11-25 03:37:45 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-11-25 03:37:45 +0100 |
| commit | 9af248e8a78f111a39d507f199d56eb8af6e52d6 (patch) | |
| tree | 4b86561a5fea5f22d8d51c5b2a029cad98feaa25 /ft_strdup.s | |
| parent | c0bcb694bbcef0273d6e6fa93854ce6a10432b87 (diff) | |
| download | libasm-9af248e8a78f111a39d507f199d56eb8af6e52d6.tar.gz libasm-9af248e8a78f111a39d507f199d56eb8af6e52d6.tar.bz2 libasm-9af248e8a78f111a39d507f199d56eb8af6e52d6.zip | |
ft_atoi_base.s kinda done
Diffstat (limited to 'ft_strdup.s')
| -rw-r--r-- | ft_strdup.s | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ft_strdup.s b/ft_strdup.s index 8ff46b5..a31f36f 100644 --- a/ft_strdup.s +++ b/ft_strdup.s @@ -21,14 +21,19 @@ _ft_strdup: push rdi ; save rdi because it will be overwrite for malloc call _ft_strlen ; rdi is still == str - inc rax ; len++ for '\0' + inc rax ; len++ for '\0' - mov rdi, rax ; size to malloc + mov rdi, rax ; size to malloc call _malloc + cmp rax, 0 + je FT_STRDUP_ERROR - pop rsi ; original str as src - mov rdi, rax ; allocated as dest + pop rsi ; original str as src + mov rdi, rax ; allocated as dest call _ft_strcpy ret +FT_STRDUP_ERROR: + pop rdi + ret |
