Skip to content

Commit

Permalink
Expose a bit of lhash/conf for Ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
samuel40791765 committed Nov 14, 2024
1 parent f0c9b3a commit b9cc7b4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
4 changes: 0 additions & 4 deletions crypto/conf/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ extern "C" {

DEFINE_LHASH_OF(CONF_VALUE)

struct conf_st {
LHASH_OF(CONF_VALUE) *data;
};

// CONF_VALUE_new returns a freshly allocated and zeroed |CONF_VALUE|.
CONF_VALUE *CONF_VALUE_new(void);

Expand Down
1 change: 0 additions & 1 deletion crypto/lhash/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ typedef int (*lhash_cmp_func_helper)(lhash_cmp_func func, const void *a,
typedef uint32_t (*lhash_hash_func)(const void *a);
typedef uint32_t (*lhash_hash_func_helper)(lhash_hash_func func, const void *a);

typedef struct lhash_st _LHASH;

// OPENSSL_lh_new returns a new, empty hash table or NULL on error.
OPENSSL_EXPORT _LHASH *OPENSSL_lh_new(lhash_hash_func hash,
Expand Down
4 changes: 4 additions & 0 deletions crypto/lhash/lhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,7 @@ void OPENSSL_lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) {
// resizing is done here.
lh_maybe_resize(lh);
}

void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *), void *arg) {
OPENSSL_lh_doall_arg(lh, func, arg);
}
3 changes: 3 additions & 0 deletions include/openssl/conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct conf_value_st {
DEFINE_STACK_OF(CONF_VALUE)
DECLARE_LHASH_OF(CONF_VALUE)

struct conf_st {
LHASH_OF(CONF_VALUE) *data;
};

// NCONF_new returns a fresh, empty |CONF|, or NULL on error. The |method|
// argument must be NULL.
Expand Down
14 changes: 13 additions & 1 deletion include/openssl/lhash.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,28 @@
extern "C" {
#endif

typedef struct lhash_st _LHASH;

// lhash is an internal library and not exported for use outside BoringSSL. This
// header is provided for compatibility with code that expects OpenSSL.


// These two macros are exported for compatibility with existing callers of
// |X509V3_EXT_conf_nid|. Do not use these symbols outside BoringSSL.
#define LHASH_OF(type) struct lhash_st_##type
#define DECLARE_LHASH_OF(type) LHASH_OF(type);

OPENSSL_EXPORT void lh_doall_arg(_LHASH *lh, void (*func)(void *, void *),
void *arg);

// These two macros are the bare minimum of |LHASH| macros downstream consumers
// use.
#define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \
void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \
o_type *a = arg1; \
a_type *b = arg2; \
name##_doall_arg(a, b); }
#define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG


#if defined(__cplusplus)
} // extern C
Expand Down

0 comments on commit b9cc7b4

Please sign in to comment.