=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/cvs/root.c,v retrieving revision 1.21 retrieving revision 1.22 diff -c -r1.21 -r1.22 *** src/usr.bin/cvs/root.c 2005/07/25 12:13:08 1.21 --- src/usr.bin/cvs/root.c 2005/08/09 10:33:46 1.22 *************** *** 1,4 **** ! /* $OpenBSD: root.c,v 1.21 2005/07/25 12:13:08 xsa Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. --- 1,4 ---- ! /* $OpenBSD: root.c,v 1.22 2005/08/09 10:33:46 joris Exp $ */ /* * Copyright (c) 2004 Jean-Francois Brousseau * All rights reserved. *************** *** 65,76 **** * increases the reference count). Otherwise, it does the parsing and adds * the result to the cache for future hits. */ - static struct cvsroot **cvs_rcache = NULL; - static u_int cvs_rcsz = 0; - - - /* * cvsroot_parse() * --- 65,72 ---- * increases the reference count). Otherwise, it does the parsing and adds * the result to the cache for future hits. */ + static TAILQ_HEAD(, cvsroot) cvs_rcache = TAILQ_HEAD_INITIALIZER(cvs_rcache); /* * cvsroot_parse() * *************** *** 86,98 **** { u_int i; char *cp, *sp, *pp; - void *tmp; struct cvsroot *root; ! for (i = 0; i < cvs_rcsz; i++) { ! if (strcmp(str, cvs_rcache[i]->cr_str) == 0) { ! cvs_rcache[i]->cr_ref++; ! return (cvs_rcache[i]); } } --- 82,99 ---- { u_int i; char *cp, *sp, *pp; struct cvsroot *root; ! /* ! * Look if we have it in cache, if we found it add it to the cache ! * at the first position again. ! */ ! TAILQ_FOREACH(root, &cvs_rcache, root_cache) { ! if (strcmp(str, root->cr_str) == 0) { ! TAILQ_REMOVE(&cvs_rcache, root, root_cache); ! TAILQ_INSERT_HEAD(&cvs_rcache, root, root_cache); ! root->cr_ref++; ! return (root); } } *************** *** 214,226 **** } /* add to the cache */ ! tmp = realloc(cvs_rcache, (cvs_rcsz + 1) * sizeof(struct cvsroot *)); ! if (tmp != NULL) { ! cvs_rcache = (struct cvsroot **)tmp; ! cvs_rcache[cvs_rcsz++] = root; ! root->cr_ref++; ! } ! return (root); } --- 215,221 ---- } /* add to the cache */ ! TAILQ_INSERT_HEAD(&cvs_rcache, root, root_cache); return (root); } *************** *** 236,241 **** --- 231,237 ---- { root->cr_ref--; if (root->cr_ref == 0) { + TAILQ_REMOVE(&cvs_rcache, root, root_cache); if (root->cr_str != NULL) free(root->cr_str); if (root->cr_buf != NULL)