diff options
author | djm <> | 2010-10-01 22:59:01 +0000 |
---|---|---|
committer | djm <> | 2010-10-01 22:59:01 +0000 |
commit | fe047d8b632246cb2db3234a0a4f32e5c318857b (patch) | |
tree | 939b752540947d33507b3acc48d76a8bfb7c3dc3 /src/lib/libcrypto/ex_data.c | |
parent | 2ea67f4aa254b09ded62e6e14fc893bbe6381579 (diff) | |
download | openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.gz openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.tar.bz2 openbsd-fe047d8b632246cb2db3234a0a4f32e5c318857b.zip |
resolve conflicts, fix local changes
Diffstat (limited to 'src/lib/libcrypto/ex_data.c')
-rw-r--r-- | src/lib/libcrypto/ex_data.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/src/lib/libcrypto/ex_data.c b/src/lib/libcrypto/ex_data.c index 3b11e7a556..e2bc8298d0 100644 --- a/src/lib/libcrypto/ex_data.c +++ b/src/lib/libcrypto/ex_data.c | |||
@@ -245,18 +245,21 @@ typedef struct st_ex_class_item { | |||
245 | static int ex_class = CRYPTO_EX_INDEX_USER; | 245 | static int ex_class = CRYPTO_EX_INDEX_USER; |
246 | 246 | ||
247 | /* The global hash table of EX_CLASS_ITEM items */ | 247 | /* The global hash table of EX_CLASS_ITEM items */ |
248 | static LHASH *ex_data = NULL; | 248 | DECLARE_LHASH_OF(EX_CLASS_ITEM); |
249 | static LHASH_OF(EX_CLASS_ITEM) *ex_data = NULL; | ||
249 | 250 | ||
250 | /* The callbacks required in the "ex_data" hash table */ | 251 | /* The callbacks required in the "ex_data" hash table */ |
251 | static unsigned long ex_hash_cb(const void *a_void) | 252 | static unsigned long ex_class_item_hash(const EX_CLASS_ITEM *a) |
252 | { | 253 | { |
253 | return ((const EX_CLASS_ITEM *)a_void)->class_index; | 254 | return a->class_index; |
254 | } | 255 | } |
255 | static int ex_cmp_cb(const void *a_void, const void *b_void) | 256 | static IMPLEMENT_LHASH_HASH_FN(ex_class_item, EX_CLASS_ITEM) |
257 | |||
258 | static int ex_class_item_cmp(const EX_CLASS_ITEM *a, const EX_CLASS_ITEM *b) | ||
256 | { | 259 | { |
257 | return (((const EX_CLASS_ITEM *)a_void)->class_index - | 260 | return a->class_index - b->class_index; |
258 | ((const EX_CLASS_ITEM *)b_void)->class_index); | ||
259 | } | 261 | } |
262 | static IMPLEMENT_LHASH_COMP_FN(ex_class_item, EX_CLASS_ITEM) | ||
260 | 263 | ||
261 | /* Internal functions used by the "impl_default" implementation to access the | 264 | /* Internal functions used by the "impl_default" implementation to access the |
262 | * state */ | 265 | * state */ |
@@ -265,7 +268,8 @@ static int ex_data_check(void) | |||
265 | { | 268 | { |
266 | int toret = 1; | 269 | int toret = 1; |
267 | CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); | 270 | CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); |
268 | if(!ex_data && ((ex_data = lh_new(ex_hash_cb, ex_cmp_cb)) == NULL)) | 271 | if(!ex_data |
272 | && (ex_data = lh_EX_CLASS_ITEM_new()) == NULL) | ||
269 | toret = 0; | 273 | toret = 0; |
270 | CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); | 274 | CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); |
271 | return toret; | 275 | return toret; |
@@ -298,7 +302,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index) | |||
298 | EX_DATA_CHECK(return NULL;) | 302 | EX_DATA_CHECK(return NULL;) |
299 | d.class_index = class_index; | 303 | d.class_index = class_index; |
300 | CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); | 304 | CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); |
301 | p = lh_retrieve(ex_data, &d); | 305 | p = lh_EX_CLASS_ITEM_retrieve(ex_data, &d); |
302 | if(!p) | 306 | if(!p) |
303 | { | 307 | { |
304 | gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM)); | 308 | gen = OPENSSL_malloc(sizeof(EX_CLASS_ITEM)); |
@@ -313,7 +317,7 @@ static EX_CLASS_ITEM *def_get_class(int class_index) | |||
313 | { | 317 | { |
314 | /* Because we're inside the ex_data lock, the | 318 | /* Because we're inside the ex_data lock, the |
315 | * return value from the insert will be NULL */ | 319 | * return value from the insert will be NULL */ |
316 | lh_insert(ex_data, gen); | 320 | (void)lh_EX_CLASS_ITEM_insert(ex_data, gen); |
317 | p = gen; | 321 | p = gen; |
318 | } | 322 | } |
319 | } | 323 | } |
@@ -375,8 +379,8 @@ static int int_new_class(void) | |||
375 | static void int_cleanup(void) | 379 | static void int_cleanup(void) |
376 | { | 380 | { |
377 | EX_DATA_CHECK(return;) | 381 | EX_DATA_CHECK(return;) |
378 | lh_doall(ex_data, def_cleanup_cb); | 382 | lh_EX_CLASS_ITEM_doall(ex_data, def_cleanup_cb); |
379 | lh_free(ex_data); | 383 | lh_EX_CLASS_ITEM_free(ex_data); |
380 | ex_data = NULL; | 384 | ex_data = NULL; |
381 | impl = NULL; | 385 | impl = NULL; |
382 | } | 386 | } |
@@ -452,7 +456,7 @@ static int int_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, | |||
452 | return 0; | 456 | return 0; |
453 | CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); | 457 | CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA); |
454 | mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); | 458 | mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth); |
455 | j = sk_num(from->sk); | 459 | j = sk_void_num(from->sk); |
456 | if(j < mx) | 460 | if(j < mx) |
457 | mx = j; | 461 | mx = j; |
458 | if(mx > 0) | 462 | if(mx > 0) |
@@ -523,7 +527,7 @@ skip: | |||
523 | OPENSSL_free(storage); | 527 | OPENSSL_free(storage); |
524 | if(ad->sk) | 528 | if(ad->sk) |
525 | { | 529 | { |
526 | sk_free(ad->sk); | 530 | sk_void_free(ad->sk); |
527 | ad->sk=NULL; | 531 | ad->sk=NULL; |
528 | } | 532 | } |
529 | } | 533 | } |
@@ -596,24 +600,24 @@ int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val) | |||
596 | 600 | ||
597 | if (ad->sk == NULL) | 601 | if (ad->sk == NULL) |
598 | { | 602 | { |
599 | if ((ad->sk=sk_new_null()) == NULL) | 603 | if ((ad->sk=sk_void_new_null()) == NULL) |
600 | { | 604 | { |
601 | CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); | 605 | CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); |
602 | return(0); | 606 | return(0); |
603 | } | 607 | } |
604 | } | 608 | } |
605 | i=sk_num(ad->sk); | 609 | i=sk_void_num(ad->sk); |
606 | 610 | ||
607 | while (i <= idx) | 611 | while (i <= idx) |
608 | { | 612 | { |
609 | if (!sk_push(ad->sk,NULL)) | 613 | if (!sk_void_push(ad->sk,NULL)) |
610 | { | 614 | { |
611 | CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); | 615 | CRYPTOerr(CRYPTO_F_CRYPTO_SET_EX_DATA,ERR_R_MALLOC_FAILURE); |
612 | return(0); | 616 | return(0); |
613 | } | 617 | } |
614 | i++; | 618 | i++; |
615 | } | 619 | } |
616 | sk_set(ad->sk,idx,val); | 620 | sk_void_set(ad->sk,idx,val); |
617 | return(1); | 621 | return(1); |
618 | } | 622 | } |
619 | 623 | ||
@@ -623,10 +627,10 @@ void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx) | |||
623 | { | 627 | { |
624 | if (ad->sk == NULL) | 628 | if (ad->sk == NULL) |
625 | return(0); | 629 | return(0); |
626 | else if (idx >= sk_num(ad->sk)) | 630 | else if (idx >= sk_void_num(ad->sk)) |
627 | return(0); | 631 | return(0); |
628 | else | 632 | else |
629 | return(sk_value(ad->sk,idx)); | 633 | return(sk_void_value(ad->sk,idx)); |
630 | } | 634 | } |
631 | 635 | ||
632 | IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS) | 636 | IMPLEMENT_STACK_OF(CRYPTO_EX_DATA_FUNCS) |