#define DS_BSIZE 128
static int save_cidx = -1; /* Saved index of currently scanned directory. */
-
static struct dsitem *dstack = NULL; /* Directory stack data... */
static int dssize = 0; /* Directory stack (allocated) size... */
static int dsidx = 0; /* First free item index... */
-
static struct scrit c1, c2; /* search criteria */
+/* Clears directory stack. */
+static void clearstack(void)
+{
+ save_cidx = -1;
+ while (dsidx > 0) {
+ dsidx--;
+ free(dstack[dsidx].path);
+ }
+}
+
/* Puts new item onto directory stack. */
static int addstack(char *uname, struct dir *dir, int pidx)
{
if (dsidx >= dssize) {
dssize += DS_BSIZE;
tmpds = realloc(dstack, dssize * sizeof(struct dsitem));
- if (tmpds == NULL)
+ if (tmpds == NULL) {
+ clearstack();
+ free(dstack);
return -1;
+ }
dstack = tmpds;
}
return -1;
}
-/* Clears directory stack. */
-static void clearstack(void)
-{
- save_cidx = -1;
- while (dsidx > 0) {
- dsidx--;
- free(dstack[dsidx].path);
- }
-}
-
/* Looks up for an opened adouble structure, opens resource fork of selected file.
* FIXME What about noadouble?
*/