- CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
- CRYPTO_EX_free *free_func)
- {
- EX_CLASS_ITEM *item = def_get_class(class_index);
- if(!item)
- return -1;
- return def_add_index(item, argl, argp, new_func, dup_func, free_func);
- }
-
-/* Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries in
- * the lock, then using them outside the lock. NB: Thread-safety only applies to
- * the global "ex_data" state (ie. class definitions), not thread-safe on 'ad'
- * itself. */
-static int int_new_ex_data(int class_index, void *obj,
- CRYPTO_EX_DATA *ad)
- {
- int mx,i;
- void *ptr;
- CRYPTO_EX_DATA_FUNCS **storage = NULL;
- EX_CLASS_ITEM *item = def_get_class(class_index);
- if(!item)
- /* error is already set */
- return 0;
- ad->sk = NULL;
- CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
- mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
- if(mx > 0)
- {
- storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS*));
- if(!storage)
- goto skip;
- for(i = 0; i < mx; i++)
- storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth,i);
- }
-skip:
- CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
- if((mx > 0) && !storage)
- {
- CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA,ERR_R_MALLOC_FAILURE);
- return 0;
- }
- for(i = 0; i < mx; i++)
- {
- if(storage[i] && storage[i]->new_func)
- {
- ptr = CRYPTO_get_ex_data(ad, i);
- storage[i]->new_func(obj,ptr,ad,i,
- storage[i]->argl,storage[i]->argp);
- }
- }
- if(storage)
- OPENSSL_free(storage);
- return 1;
- }
+ CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func,
+ CRYPTO_EX_free *free_func)
+{
+ EX_CLASS_ITEM *item = def_get_class(class_index);
+ if (!item)
+ return -1;
+ return def_add_index(item, argl, argp, new_func, dup_func, free_func);
+}
+
+/*
+ * Thread-safe by copying a class's array of "CRYPTO_EX_DATA_FUNCS" entries
+ * in the lock, then using them outside the lock. NB: Thread-safety only
+ * applies to the global "ex_data" state (ie. class definitions), not
+ * thread-safe on 'ad' itself.
+ */
+static int int_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad)
+{
+ int mx, i;
+ void *ptr;
+ CRYPTO_EX_DATA_FUNCS **storage = NULL;
+ EX_CLASS_ITEM *item = def_get_class(class_index);
+ if (!item)
+ /* error is already set */
+ return 0;
+ ad->sk = NULL;
+ CRYPTO_r_lock(CRYPTO_LOCK_EX_DATA);
+ mx = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth);
+ if (mx > 0) {
+ storage = OPENSSL_malloc(mx * sizeof(CRYPTO_EX_DATA_FUNCS *));
+ if (!storage)
+ goto skip;
+ for (i = 0; i < mx; i++)
+ storage[i] = sk_CRYPTO_EX_DATA_FUNCS_value(item->meth, i);
+ }
+ skip:
+ CRYPTO_r_unlock(CRYPTO_LOCK_EX_DATA);
+ if ((mx > 0) && !storage) {
+ CRYPTOerr(CRYPTO_F_INT_NEW_EX_DATA, ERR_R_MALLOC_FAILURE);
+ return 0;
+ }
+ for (i = 0; i < mx; i++) {
+ if (storage[i] && storage[i]->new_func) {
+ ptr = CRYPTO_get_ex_data(ad, i);
+ storage[i]->new_func(obj, ptr, ad, i,
+ storage[i]->argl, storage[i]->argp);
+ }
+ }
+ if (storage)
+ OPENSSL_free(storage);
+ return 1;
+}