robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
38986188ba
master
1#pragma once 2 3#include <stddef.h> 4 5#include "nvim/hashtab_defs.h" // IWYU pragma: keep 6 7/// Magic number used for hashitem "hi_key" value indicating a deleted item 8/// 9/// Only the address is used. 10extern char hash_removed ; 11 12/// The address of "hash_removed" is used as a magic number 13/// for hi_key to indicate a removed item. 14#define HI_KEY_REMOVED (&hash_removed) 15#define HASHITEM_EMPTY (hi ) ((hi)->hi_key == NULL || (hi)->hi_key == &hash_removed) 16 17/// Iterate over a hashtab 18/// 19/// @param[in] ht Hashtab to iterate over. 20/// @param hi Name of the variable with current hashtab entry. 21/// @param code Cycle body. 22#define HASHTAB_ITER (ht ,hi ,code ) \ 23 do { \ 24 hashtab_T *const hi##ht_ = (ht); \ 25 size_t hi##todo_ = hi##ht_->ht_used; \ 26 for (hashitem_T *hi = hi##ht_->ht_array; hi##todo_; hi++) { \ 27 if (!HASHITEM_EMPTY(hi)) { \ 28 hi##todo_--; \ 29 { \ 30 code \ 31 } \ 32 } \ 33 } \ 34 } while (0) 35 36#include "hashtab.h.generated.h"