aboutsummaryrefslogtreecommitdiff
path: root/crypto/stack
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>1999-05-30 15:25:47 +0000
committerBen Laurie <ben@openssl.org>1999-05-30 15:25:47 +0000
commitee8ba0b26c101262521a0bc10233cdd5a136d126 (patch)
tree0d21ce8dd4940180b7604c60d4a83950315a426d /crypto/stack
parent838d25a1ec0011fde245a22ac1cf6cddc518ddfb (diff)
downloadopenssl-ee8ba0b26c101262521a0bc10233cdd5a136d126.zip
openssl-ee8ba0b26c101262521a0bc10233cdd5a136d126.tar.gz
openssl-ee8ba0b26c101262521a0bc10233cdd5a136d126.tar.bz2
Another safe stack.
Diffstat (limited to 'crypto/stack')
-rw-r--r--crypto/stack/safestack.h7
-rw-r--r--crypto/stack/stack.c20
-rw-r--r--crypto/stack/stack.h1
3 files changed, 20 insertions, 8 deletions
diff --git a/crypto/stack/safestack.h b/crypto/stack/safestack.h
index d0823c0..3893498 100644
--- a/crypto/stack/safestack.h
+++ b/crypto/stack/safestack.h
@@ -82,7 +82,8 @@ int (*sk_##type##_set_cmp_func(STACK_OF(type) *sk, \
STACK_OF(type) *sk_##type##_dup(STACK_OF(type) *sk); \
void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)); \
type *sk_##type##_shift(STACK_OF(type) *sk); \
-type *sk_##type##_pop(STACK_OF(type) *sk);
+type *sk_##type##_pop(STACK_OF(type) *sk); \
+void sk_##type##_sort(STACK_OF(type) *sk);
#define IMPLEMENT_STACK_OF(type) \
STACK_OF(type) *sk_##type##_new(int (*cmp)(type **,type **)) \
@@ -121,6 +122,8 @@ void sk_##type##_pop_free(STACK_OF(type) *sk,void (*func)(type *)) \
type *sk_##type##_shift(STACK_OF(type) *sk) \
{ return (type *)sk_shift((STACK *)sk); } \
type *sk_##type##_pop(STACK_OF(type) *sk) \
- { return (type *)sk_pop((STACK *)sk); }
+ { return (type *)sk_pop((STACK *)sk); } \
+void sk_##type##_sort(STACK_OF(type) *sk) \
+ { sk_sort((STACK *)sk); }
#endif /* ndef HEADER_SAFESTACK_H */
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c
index f1165b3..8b96713 100644
--- a/crypto/stack/stack.c
+++ b/crypto/stack/stack.c
@@ -217,13 +217,9 @@ int sk_find(STACK *st, char *data)
return(i);
return(-1);
}
- comp_func=(int (*)())st->comp;
- if (!st->sorted)
- {
- qsort((char *)st->data,st->num,sizeof(char *),FP_ICC comp_func);
- st->sorted=1;
- }
+ sk_sort(st);
if (data == NULL) return(-1);
+ comp_func=(int (*)())st->comp;
r=(char **)bsearch(&data,(char *)st->data,
st->num,sizeof(char *),FP_ICC comp_func);
if (r == NULL) return(-1);
@@ -301,3 +297,15 @@ char *sk_set(STACK *st, int i, char *value)
if(st == NULL) return NULL;
return (st->data[i] = value);
}
+
+void sk_sort(STACK *st)
+ {
+ if (!st->sorted)
+ {
+ int (*comp_func)();
+
+ comp_func=(int (*)())st->comp;
+ qsort(st->data,st->num,sizeof(char *),FP_ICC comp_func);
+ st->sorted=1;
+ }
+ }
diff --git a/crypto/stack/stack.h b/crypto/stack/stack.h
index ec629d0..0f825cc 100644
--- a/crypto/stack/stack.h
+++ b/crypto/stack/stack.h
@@ -98,6 +98,7 @@ char *sk_pop(STACK *st);
void sk_zero(STACK *st);
int (*sk_set_cmp_func(STACK *sk, int (*c)()))();
STACK *sk_dup(STACK *st);
+void sk_sort(STACK *st);
#ifdef __cplusplus
}