#define YYEXPAND(x)     TclDateExpand(x)

int
TclDateExpand(maxDepth)
    int maxDepth;
{
    int result;

    result = 2 * maxDepth; /* double table size */

    if (maxDepth == YYMAXDEPTH) { /* first time growth */
        /* NOTE: uses ckalloc */
        char *newTclDates = (char *)ckalloc(sizeof(int) * result);
        char *newTclDatev = (char *)ckalloc(sizeof(YYSTYPE) * result);
        if (newTclDates != 0 && newTclDatev != 0) {
            TclDates = YYCOPY(newTclDates, TclDates, int);
            TclDatev = YYCOPY(newTclDatev, TclDatev, YYSTYPE);
        } else
            result = 0; /* failed */
    } else { /* not first time */
        /* NOTE: uses ckrealloc */
        TclDates = (int *)ckrealloc((char *)TclDates, result * sizeof(int));
        TclDatev = (YYSTYPE *)ckrealloc((char *)TclDatev, result * sizeof(YYSTYPE));
        if (TclDates == 0 || TclDatev == 0) {
            result = 0; /* failed */
        }
    }

    return result;
}


void
TclFinalizeDate(void)
{
    /*
     * Free them if they are non-NULL and if
     * they not pointing to the arrays.
     */
    if (TclDates != NULL && TclDates != TclDate_TclDates) {
        ckfree((char *)TclDates);
        TclDates = NULL;
    }

    if (TclDatev != NULL && TclDatev != TclDate_TclDatev) {
        ckfree((char *)TclDatev);
        TclDatev = NULL;
    }
}
