From 08ef84ec7d146d92bd7783efe0f7a7f3296ce8e5 Mon Sep 17 00:00:00 2001 From: zhanghuanhuan Date: Tue, 31 Oct 2023 16:57:15 +0800 Subject: [PATCH] add assoc_reference func for assoc file --- bash-5.1/r_assoc/src/lib.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/bash-5.1/r_assoc/src/lib.rs b/bash-5.1/r_assoc/src/lib.rs index bff665a..221bd08 100644 --- a/bash-5.1/r_assoc/src/lib.rs +++ b/bash-5.1/r_assoc/src/lib.rs @@ -63,6 +63,19 @@ macro_rules! RESIZE_MALLOCED_BUFFER { } } +#[macro_export] +macro_rules! REVERSE_LIST { + ($list:expr,$type:ty) => { + if !$list.is_null() && !((*$list).next).is_null() { + list_reverse($list as *mut GENERIC_LIST) as $type + } + else { + $list as $type + } + } + +} + #[no_mangle] pub unsafe extern "C" fn assoc_dispose(mut hash: *mut HASH_TABLE) { if !hash.is_null() { @@ -117,3 +130,21 @@ pub unsafe extern "C" fn assoc_remove( } } +#[no_mangle] +pub unsafe extern "C" fn assoc_reference( + mut hash: *mut HASH_TABLE, + mut string: *mut libc::c_char, +) -> *mut libc::c_char { + let mut b: *mut BUCKET_CONTENTS = 0 as *mut BUCKET_CONTENTS; + if hash.is_null() { + return 0 as *mut libc::c_char; + } + b = hash_search(string, hash, 0 as libc::c_int); + return if !b.is_null() { + (*b).data as *mut libc::c_char + } else { + 0 as *mut libc::c_char + }; +} +#[no_mangle] + -- Gitee