-/* $OpenBSD: suff.c,v 1.23 2000/03/14 19:00:32 espie Exp $ */
+/* $OpenBSD: suff.c,v 1.24 2000/03/26 15:51:31 espie Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
#if 0
static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94";
#else
-static char rcsid[] = "$OpenBSD: suff.c,v 1.23 2000/03/14 19:00:32 espie Exp $";
+static char rcsid[] = "$OpenBSD: suff.c,v 1.24 2000/03/26 15:51:31 espie Exp $";
#endif
#endif /* not lint */
Lst searchPath; /* The path along which files of this suffix
* may be found */
int sNum; /* The suffix number */
- int refCount; /* Reference count of list membership */
Lst parents; /* Suffixes we have a transformation to */
Lst children; /* Suffixes we have a transformation from */
Lst ref; /* List of lists this suffix is referenced */
static void SuffUnRef __P((ClientData, ClientData));
static void SuffFree __P((ClientData));
static void SuffInsert __P((Lst, Suff *));
-static Suff *SuffRemove __P((Lst, Suff *));
+static void SuffRemove __P((Lst, Suff *));
static Boolean SuffParseTransform __P((char *, Suff **, Suff **));
static int SuffRebuildGraph __P((ClientData, ClientData));
static int SuffAddSrc __P((ClientData, ClientData));
Lst l = (Lst) lp;
LstNode ln = Lst_Member(l, sp);
- if (ln != NULL) {
+ if (ln != NULL)
Lst_Remove(l, ln);
- ((Suff *) sp)->refCount--;
- }
}
/*-
if (s == emptySuff)
emptySuff = NULL;
-#ifdef notdef
- /* We don't delete suffixes in order, so we cannot use this */
- if (s->refCount)
- Punt("Internal error deleting suffix `%s' with refcount = %d", s->name,
- s->refCount);
-#endif
-
Lst_Destroy (s->ref, NOFREE);
Lst_Destroy (s->children, NOFREE);
Lst_Destroy (s->parents, NOFREE);
/*-
*-----------------------------------------------------------------------
* SuffRemove --
- * Remove the suffix into the list
- *
- * Results:
- * None
- *
- * Side Effects:
- * The reference count for the suffix is decremented and the
- * suffix is possibly freed
+ * Remove the suffix from the list
*-----------------------------------------------------------------------
*/
-static Suff *
+static void
SuffRemove(l, s)
Lst l;
Suff *s;
{
SuffUnRef((ClientData) l, (ClientData) s);
-#if 0
- if (s->refCount == 0) {
- SuffUnRef ((ClientData) sufflist, (ClientData) s);
- SuffFree((ClientData) s);
- s = NULL;
- }
-#endif
- return (s);
}
\f
/*-
printf("at end of list\n");
}
Lst_AtEnd (l, (ClientData)s);
- s->refCount++;
Lst_AtEnd(s->ref, (ClientData) l);
} else if (s2->sNum != s->sNum) {
if (DEBUG(SUFF)) {
printf("before %s(%d)\n", s2->name, s2->sNum);
}
Lst_Insert(l, ln, (ClientData)s);
- s->refCount++;
Lst_AtEnd(s->ref, (ClientData) l);
} else if (DEBUG(SUFF)) {
printf("already there\n");
}
/*
- * Remove the source from the target's children list. We check for a
- * null return to handle a beanhead saying something like
- * .c.o .c.o:
+ * Remove the source from the target's children list.
*
* We'll be called twice when the next target is seen, but .c and .o
* are only linked once...
*/
- s = SuffRemove(t->children, s);
+ SuffRemove(t->children, s);
/*
* Remove the target from the source's parents list
*/
- if (s != NULL)
- SuffRemove(s->parents, t);
+ SuffRemove(s->parents, t);
} else if ((gn->type & OP_TRANSFORM) && DEBUG(SUFF)) {
printf("transformation %s complete\n", gn->name);
}
s->ref = Lst_Init();
s->sNum = sNum++;
s->flags = 0;
- s->refCount = 0;
Lst_AtEnd(sufflist, (ClientData)s);
/*
s2->parent = targ;
s2->node = NULL;
s2->suff = s;
- s->refCount++;
s2->children = 0;
targ->children += 1;
Lst_AtEnd(ls->l, (ClientData)s2);
s2->parent = targ;
s2->node = NULL;
s2->suff = s;
- s->refCount++;
s2->children = 0;
targ->children += 1;
Lst_AtEnd(ls->l, (ClientData)s2);
ret->file = estrdup(s->name);
ret->pref = targ->pref;
ret->suff = suff;
- suff->refCount++;
ret->parent = targ;
ret->node = s;
ret->children = 0;
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
targ->suff = (Suff *)Lst_Datum(ln);
- targ->suff->refCount++;
targ->node = gn;
targ->parent = (Src *)NULL;
targ->children = 0;
targ = (Src *)emalloc(sizeof (Src));
targ->file = estrdup(gn->name);
targ->suff = suffNull;
- targ->suff->refCount++;
targ->node = gn;
targ->parent = (Src *)NULL;
targ->children = 0;
int savep = strlen(gn->path) - targ->suff->nameLen;
char savec;
- if (gn->suffix)
- gn->suffix->refCount--;
gn->suffix = targ->suff;
- gn->suffix->refCount++;
savec = gn->path[savep];
gn->path[savep] = '\0';
* The .PREFIX gets the full path if the target has
* no known suffix.
*/
- if (gn->suffix)
- gn->suffix->refCount--;
gn->suffix = NULL;
if ((ptr = strrchr(gn->path, '/')) != NULL)
* path to be the name so Dir_MTime won't go grovelling for
* it.
*/
- if (gn->suffix)
- gn->suffix->refCount--;
gn->suffix = (targ == NULL) ? NULL : targ->suff;
- if (gn->suffix)
- gn->suffix->refCount++;
efree(gn->path);
gn->path = estrdup(gn->name);
}
for (src = bottom; src->parent != (Src *)NULL; src = src->parent) {
targ = src->parent;
- if (src->node->suffix)
- src->node->suffix->refCount--;
src->node->suffix = src->suff;
- src->node->suffix->refCount++;
if (targ->node == NULL) {
targ->node = Targ_FindNode(targ->file, TARG_CREATE);
}
}
- if (gn->suffix)
- gn->suffix->refCount--;
gn->suffix = src->suff;
- gn->suffix->refCount++;
/*
* So Dir_MTime doesn't go questing for it...
Suff *s;
ln = Lst_Find(sufflist, SuffSuffHasNameP, (ClientData)LIBSUFF);
- if (gn->suffix)
- gn->suffix->refCount--;
if (ln != NULL) {
gn->suffix = s = (Suff *) Lst_Datum (ln);
- gn->suffix->refCount++;
Arch_FindLib (gn, s->searchPath);
} else {
gn->suffix = NULL;
suffNull->ref = Lst_Init();
suffNull->sNum = sNum++;
suffNull->flags = SUFF_NULL;
- suffNull->refCount = 1;
}
int flags;
int flag;
- printf ("# `%s' [%d] ", s->name, s->refCount);
+ printf ("# `%s' ", s->name);
flags = s->flags;
if (flags) {