diff options
author | LibArchive Upstream <libarchive-discuss@googlegroups.com> | 2020-02-11 21:49:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-02-13 17:57:28 (GMT) |
commit | 8cce62295a5ddca3e0d1fd7cff0229054972dfe3 (patch) | |
tree | 1114d426e2e581164d202a456b31aacc6c94dfb1 /libarchive/archive_rb.h | |
parent | 2aaed7a05053c3bcbebbff5ae1beb51e590b3ad1 (diff) | |
download | CMake-8cce62295a5ddca3e0d1fd7cff0229054972dfe3.zip CMake-8cce62295a5ddca3e0d1fd7cff0229054972dfe3.tar.gz CMake-8cce62295a5ddca3e0d1fd7cff0229054972dfe3.tar.bz2 |
LibArchive 2020-02-11 (3288ebb0)
Code extracted from:
https://github.com/libarchive/libarchive.git
at commit 3288ebb0353beb51dfb09d444dedbe9235ead53d (v3.4.2).
Diffstat (limited to 'libarchive/archive_rb.h')
-rw-r--r-- | libarchive/archive_rb.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libarchive/archive_rb.h b/libarchive/archive_rb.h index 4562e9e..8851f10 100644 --- a/libarchive/archive_rb.h +++ b/libarchive/archive_rb.h @@ -28,8 +28,9 @@ * * Based on NetBSD: rb.h,v 1.13 2009/08/16 10:57:01 yamt Exp */ -#ifndef ARCHIVE_RB_H_ -#define ARCHIVE_RB_H_ + +#ifndef ARCHIVE_RB_H_INCLUDED +#define ARCHIVE_RB_H_INCLUDED struct archive_rb_node { struct archive_rb_node *rb_nodes[2]; @@ -48,12 +49,24 @@ struct archive_rb_node { __archive_rb_tree_iterate((T), NULL, ARCHIVE_RB_DIR_LEFT) #define ARCHIVE_RB_TREE_MAX(T) \ __archive_rb_tree_iterate((T), NULL, ARCHIVE_RB_DIR_RIGHT) +#define ARCHIVE_RB_TREE_NEXT(T, N) \ + __archive_rb_tree_iterate((T), (N), ARCHIVE_RB_DIR_RIGHT) +#define ARCHIVE_RB_TREE_PREV(T, N) \ + __archive_rb_tree_iterate((T), (N), ARCHIVE_RB_DIR_LEFT) #define ARCHIVE_RB_TREE_FOREACH(N, T) \ for ((N) = ARCHIVE_RB_TREE_MIN(T); (N); \ - (N) = __archive_rb_tree_iterate((T), (N), ARCHIVE_RB_DIR_RIGHT)) + (N) = ARCHIVE_RB_TREE_NEXT((T), (N))) #define ARCHIVE_RB_TREE_FOREACH_REVERSE(N, T) \ for ((N) = ARCHIVE_RB_TREE_MAX(T); (N); \ - (N) = __archive_rb_tree_iterate((T), (N), ARCHIVE_RB_DIR_LEFT)) + (N) = ARCHIVE_RB_TREE_PREV((T), (N))) +#define ARCHIVE_RB_TREE_FOREACH_SAFE(N, T, S) \ + for ((N) = ARCHIVE_RB_TREE_MIN(T); \ + (N) && ((S) = ARCHIVE_RB_TREE_NEXT((T), (N)), 1); \ + (N) = (S)) +#define ARCHIVE_RB_TREE_FOREACH_REVERSE_SAFE(N, T, S) \ + for ((N) = ARCHIVE_RB_TREE_MAX(T); \ + (N) && ((S) = ARCHIVE_RB_TREE_PREV((T), (N)), 1); \ + (N) = (S)) /* * archive_rbto_compare_nodes_fn: |