summaryrefslogtreecommitdiff
path: root/usr.bin/cvs
diff options
context:
space:
mode:
authorJoris Vink <joris@cvs.openbsd.org>2007-08-30 11:19:30 +0000
committerJoris Vink <joris@cvs.openbsd.org>2007-08-30 11:19:30 +0000
commit788d40942703bbfb07315fdbc77e71da36442525 (patch)
tree771d63d1681c4fc79304f8edb335247ac191d51f /usr.bin/cvs
parent7a688e4cd584d47e586508214a4d0a3616a75985 (diff)
Remove old CVSROOT caching mechanisms.
from Tobias Stoeckmann
Diffstat (limited to 'usr.bin/cvs')
-rw-r--r--usr.bin/cvs/cvs.h5
-rw-r--r--usr.bin/cvs/root.c69
2 files changed, 6 insertions, 68 deletions
diff --git a/usr.bin/cvs/cvs.h b/usr.bin/cvs/cvs.h
index b64b506d8c2..6a7dbd096f2 100644
--- a/usr.bin/cvs/cvs.h
+++ b/usr.bin/cvs/cvs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.h,v 1.141 2007/07/03 13:22:42 joris Exp $ */
+/* $OpenBSD: cvs.h,v 1.142 2007/08/30 11:19:29 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -209,7 +209,6 @@ struct cvsroot {
char *cr_host;
char *cr_dir;
u_int cr_port;
- u_int cr_ref;
/* connection data */
u_int cr_flags;
@@ -369,9 +368,7 @@ void cvs_parse_tagfile(char *, char **, char **, int *);
void cvs_write_tagfile(const char *, char *, char *, int);
/* root.c */
-struct cvsroot *cvsroot_parse(const char *);
struct cvsroot *cvsroot_get(const char *);
-void cvsroot_remove(struct cvsroot *);
/* logmsg.c */
char * cvs_logmsg_read(const char *path);
diff --git a/usr.bin/cvs/root.c b/usr.bin/cvs/root.c
index 73e7f957606..926d0b92071 100644
--- a/usr.bin/cvs/root.c
+++ b/usr.bin/cvs/root.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: root.c,v 1.39 2007/05/11 11:29:26 xsa Exp $ */
+/* $OpenBSD: root.c,v 1.40 2007/08/30 11:19:29 joris Exp $ */
/*
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
* All rights reserved.
@@ -47,18 +47,6 @@ const char *cvs_methods[] = {
#define CVS_NBMETHODS (sizeof(cvs_methods)/sizeof(cvs_methods[0]))
/*
- * CVSROOT cache
- *
- * Whenever cvsroot_parse() gets called for a specific string, it first
- * checks in the cache to see if there is already a parsed version of the
- * same string and returns a pointer to it in case one is found (it also
- * 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);
-static void cvsroot_free(struct cvsroot *);
-
-/*
* cvsroot_parse()
*
* Parse a CVS root string (as found in CVS/Root files or the CVSROOT
@@ -68,29 +56,18 @@ static void cvsroot_free(struct cvsroot *);
* Returns a pointer to the allocated information on success, or NULL
* on failure.
*/
-struct cvsroot *
+static struct cvsroot *
cvsroot_parse(const char *str)
{
u_int i;
char *cp, *sp, *pp;
const char *errstr;
- struct cvsroot *root;
+ static struct cvsroot *root = NULL;
- /*
- * 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 (root->cr_str != NULL && 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);
- }
- }
+ if (root != NULL)
+ return (root);
root = xcalloc(1, sizeof(*root));
- root->cr_ref = 1;
root->cr_method = CVS_METHOD_NONE;
CVS_RSTVR(root);
@@ -126,7 +103,6 @@ cvsroot_parse(const char *str)
if (root->cr_method == CVS_METHOD_NONE)
root->cr_method = CVS_METHOD_LOCAL;
/* stop here, it's just a path */
- TAILQ_INSERT_HEAD(&cvs_rcache, root, root_cache);
return (root);
}
@@ -173,45 +149,10 @@ cvsroot_parse(const char *str)
root->cr_method = CVS_METHOD_LOCAL;
}
- /* add to the cache */
- TAILQ_INSERT_HEAD(&cvs_rcache, root, root_cache);
return (root);
}
/*
- * cvsroot_remove()
- *
- * Remove a CVSROOT structure from the cache, and free it.
- */
-void
-cvsroot_remove(struct cvsroot *root)
-{
- root->cr_ref--;
- if (root->cr_ref == 0) {
- TAILQ_REMOVE(&cvs_rcache, root, root_cache);
- cvsroot_free(root);
- }
-}
-
-/*
- * cvsroot_free()
- *
- * Free a CVSROOT structure previously allocated and returned by
- * cvsroot_parse().
- */
-static void
-cvsroot_free(struct cvsroot *root)
-{
- if (root->cr_str != NULL)
- xfree(root->cr_str);
- if (root->cr_buf != NULL)
- xfree(root->cr_buf);
- if (root->cr_version != NULL)
- xfree(root->cr_version);
- xfree(root);
-}
-
-/*
* cvsroot_get()
*
* Get the CVSROOT information for a specific directory <dir>. The