{
char **s;
+ if(st == NULL) return 0;
if (st->num_alloc <= st->num+1)
{
s=(char **)Realloc((char *)st->data,
char *ret;
int i,j;
- if ((st->num == 0) || (loc < 0) || (loc >= st->num)) return(NULL);
+ if ((st == NULL) || (st->num == 0) || (loc < 0)
+ || (loc >= st->num)) return(NULL);
ret=st->data[loc];
if (loc != st->num-1)
char **r;
int i;
int (*comp_func)();
+ if(st == NULL) return -1;
if (st->comp == NULL)
{
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);
Free((char *)st);
}
+int sk_num(STACK *st)
+{
+ if(st == NULL) return -1;
+ return st->num;
+}
+
+char *sk_value(STACK *st, int i)
+{
+ if(st == NULL) return NULL;
+ return st->data[i];
+}
+
+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;
+ }
+ }