struct stack_st {
int num;
- char **data;
+ const char **data;
int sorted;
int num_alloc;
OPENSSL_sk_compfunc comp;
if ((ret->data[i] = copy_func(sk->data[i])) == NULL) {
while (--i >= 0)
if (ret->data[i] != NULL)
- free_func(ret->data[i]);
+ free_func((void *)ret->data[i]);
OPENSSL_sk_free(ret);
return NULL;
}
return (NULL);
}
-int OPENSSL_sk_insert(OPENSSL_STACK *st, void *data, int loc)
+int OPENSSL_sk_insert(OPENSSL_STACK *st, const void *data, int loc)
{
- char **s;
+ const char **s;
if (st == NULL)
return 0;
if ((loc >= (int)st->num) || (loc < 0))
st->data[st->num] = data;
else {
- memmove(&(st->data[loc + 1]),
- &(st->data[loc]), sizeof(char *) * (st->num - loc));
+ memmove(&st->data[loc + 1], &st->data[loc],
+ sizeof(st->data[0]) * (st->num - loc));
st->data[loc] = data;
}
st->num++;
void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc)
{
- char *ret;
- int i, j;
+ const char *ret;
if (st == NULL || loc < 0 || loc >= st->num)
return NULL;
ret = st->data[loc];
- if (loc != st->num - 1) {
- j = st->num - 1;
- for (i = loc; i < j; i++)
- st->data[i] = st->data[i + 1];
- /*
- * In theory memcpy is not safe for this memcpy( &(st->data[loc]),
- * &(st->data[loc+1]), sizeof(char *)*(st->num-loc-1));
- */
- }
+ if (loc != st->num - 1)
+ memmove(&st->data[loc], &st->data[loc + 1],
+ sizeof(st->data[0]) * (st->num - loc - 1));
st->num--;
- return (ret);
+ return (void *)ret;
}
static int internal_find(OPENSSL_STACK *st, const void *data,
int ret_val_options)
{
- const void *const *r;
+ const void *r;
int i;
if (st == NULL)
ret_val_options);
if (r == NULL)
return (-1);
- return (int)((char **)r - st->data);
+ return (int)((const char **)r - st->data);
}
int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data)
return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH);
}
-int OPENSSL_sk_push(OPENSSL_STACK *st, void *data)
+int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data)
{
return (OPENSSL_sk_insert(st, data, st->num));
}
-int OPENSSL_sk_unshift(OPENSSL_STACK *st, void *data)
+int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data)
{
return (OPENSSL_sk_insert(st, data, 0));
}
return;
for (i = 0; i < st->num; i++)
if (st->data[i] != NULL)
- func(st->data[i]);
+ func((char *)st->data[i]);
OPENSSL_sk_free(st);
}
{
if (st == NULL || i < 0 || i >= st->num)
return NULL;
- return st->data[i];
+ return (void *)st->data[i];
}
-void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, void *value)
+void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data)
{
if (st == NULL || i < 0 || i >= st->num)
return NULL;
- return (st->data[i] = value);
+ st->data[i] = data;
+ return (void *)st->data[i];
}
void OPENSSL_sk_sort(OPENSSL_STACK *st)
void sk_TYPE_zero(const STACK_OF(TYPE) *sk);
TYPE *sk_TYPE_delete(STACK_OF(TYPE) *sk, int i);
TYPE *sk_TYPE_delete_ptr(STACK_OF(TYPE) *sk, TYPE *ptr);
- int sk_TYPE_push(STACK_OF(TYPE) *sk, TYPE *ptr);
- int sk_TYPE_unshift(STACK_OF(TYPE) *sk, TYPE *ptr);
+ int sk_TYPE_push(STACK_OF(TYPE) *sk, const TYPE *ptr);
+ int sk_TYPE_unshift(STACK_OF(TYPE) *sk, const TYPE *ptr);
TYPE *sk_TYPE_pop(STACK_OF(TYPE) *sk);
TYPE *sk_TYPE_shift(STACK_OF(TYPE) *sk);
void sk_TYPE_pop_free(STACK_OF(TYPE) *sk, sk_TYPE_freefunc freefunc);
int sk_TYPE_insert(STACK_OF(TYPE) *sk, TYPE *ptr, int idx);
- TYPE *sk_TYPE_set(STACK_OF(TYPE) *sk, int idx, TYPE *ptr);
+ TYPE *sk_TYPE_set(STACK_OF(TYPE) *sk, int idx, const TYPE *ptr);
int sk_TYPE_find(STACK_OF(TYPE) *sk, TYPE *ptr);
int sk_TYPE_find_ex(STACK_OF(TYPE) *sk, TYPE *ptr);
void sk_TYPE_sort(const STACK_OF(TYPE) *sk);
} \
static ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \
{ \
- return OPENSSL_sk_push((OPENSSL_STACK *)sk, (void *)ptr); \
+ return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \
} \
static ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \
{ \
- return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (void *)ptr); \
+ return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \
} \
static ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \
{ \
} \
static ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \
{ \
- return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (void *)ptr, idx); \
+ return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \
} \
static ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \
{ \
- return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (void *)ptr); \
+ return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \
} \
static ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \
{ \
sk_##t1##_copyfunc copyfunc, \
sk_##t1##_freefunc freefunc) \
{ \
- return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((OPENSSL_STACK *)sk, \
+ return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \
(OPENSSL_sk_copyfunc)copyfunc, \
(OPENSSL_sk_freefunc)freefunc); \
} \
int OPENSSL_sk_num(const OPENSSL_STACK *);
void *OPENSSL_sk_value(const OPENSSL_STACK *, int);
-void *OPENSSL_sk_set(OPENSSL_STACK *, int, void *);
+void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data);
OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp);
OPENSSL_STACK *OPENSSL_sk_new_null(void);
void OPENSSL_sk_free(OPENSSL_STACK *);
void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *));
OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f);
-int OPENSSL_sk_insert(OPENSSL_STACK *sk, void *data, int where);
+int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where);
void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc);
void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p);
int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data);
int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data);
-int OPENSSL_sk_push(OPENSSL_STACK *st, void *data);
-int OPENSSL_sk_unshift(OPENSSL_STACK *st, void *data);
+int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data);
+int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data);
void *OPENSSL_sk_shift(OPENSSL_STACK *st);
void *OPENSSL_sk_pop(OPENSSL_STACK *st);
void OPENSSL_sk_zero(OPENSSL_STACK *st);