tor  0.4.1.0-alpha-dev
di_ops.h
Go to the documentation of this file.
1 /* Copyright (c) 2003-2004, Roger Dingledine
2  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
3  * Copyright (c) 2007-2019, The Tor Project, Inc. */
4 /* See LICENSE for licensing information */
5 
11 #ifndef TOR_DI_OPS_H
12 #define TOR_DI_OPS_H
13 
14 #include "orconfig.h"
15 #include "lib/cc/torint.h"
16 
17 int tor_memcmp(const void *a, const void *b, size_t sz);
18 int tor_memeq(const void *a, const void *b, size_t sz);
19 #define tor_memneq(a,b,sz) (!tor_memeq((a),(b),(sz)))
20 
26 #define fast_memcmp(a,b,c) (memcmp((a),(b),(c)))
27 #define fast_memeq(a,b,c) (0==memcmp((a),(b),(c)))
28 #define fast_memneq(a,b,c) (0!=memcmp((a),(b),(c)))
29 
30 int safe_mem_is_zero(const void *mem, size_t sz);
31 
38 typedef void (*dimap_free_fn)(void *);
39 
40 void dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn);
41 #define dimap_free(map, free_fn) \
42  do { \
43  dimap_free_((map), (free_fn)); \
44  (map) = NULL; \
45  } while (0)
47  const uint8_t *key, void *val);
48 void *dimap_search(const di_digest256_map_t *map, const uint8_t *key,
49  void *dflt_val);
50 int select_array_member_cumulative_timei(const uint64_t *entries,
51  int n_entries,
52  uint64_t total, uint64_t rand_val);
53 
54 #endif /* !defined(TOR_DI_OPS_H) */
55 
int select_array_member_cumulative_timei(const uint64_t *entries, int n_entries, uint64_t total, uint64_t rand_val)
Definition: di_ops.c:256
void dimap_add_entry(di_digest256_map_t **map, const uint8_t *key, void *val)
Definition: di_ops.c:173
void dimap_free_(di_digest256_map_t *map, dimap_free_fn free_fn)
Definition: di_ops.c:156
Integer definitions used throughout Tor.
int tor_memcmp(const void *a, const void *b, size_t sz)
Definition: di_ops.c:31
int safe_mem_is_zero(const void *mem, size_t sz)
Definition: di_ops.c:221
void * dimap_search(const di_digest256_map_t *map, const uint8_t *key, void *dflt_val)
Definition: di_ops.c:197
int tor_memeq(const void *a, const void *b, size_t sz)
Definition: di_ops.c:107