summaryrefslogtreecommitdiffstats
path: root/crypto/stack/stack.c
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/stack.c
parent838d25a1ec0011fde245a22ac1cf6cddc518ddfb (diff)
Another safe stack.
Diffstat (limited to 'crypto/stack/stack.c')
-rw-r--r--crypto/stack/stack.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c
index f1165b340c..8b96713884 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;
+ }
+ }