summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ypserv/yp_dblookup.c
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>1996-05-31 16:01:51 +0000
committerwpaul <wpaul@FreeBSD.org>1996-05-31 16:01:51 +0000
commit7db7b1cde125e2f1b07ce515a44386287ffe20e3 (patch)
tree09d1229ceb91ce3fd14b2705728d76c9b2ed0f9f /usr.sbin/ypserv/yp_dblookup.c
parentd4c70b6e6444ede1b94fe2e860bc791d28cd0604 (diff)
downloadFreeBSD-src-7db7b1cde125e2f1b07ce515a44386287ffe20e3.zip
FreeBSD-src-7db7b1cde125e2f1b07ce515a44386287ffe20e3.tar.gz
Small touch-ups -- no functional changes.
Fix some comments to reflect reality (in some cases I made changes to code but not to the comments). Change some instances of 'inline' to '__inline' to pacify gcc -ansi -pedantic. Use rcsid strings more consistently. Make 'oldaddr' static in yp_access(). Use strcpy()/strcat() in yp_open_db_cache() instead of snprintf(). (Seems to be a little faster this way.)
Diffstat (limited to 'usr.sbin/ypserv/yp_dblookup.c')
-rw-r--r--usr.sbin/ypserv/yp_dblookup.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/usr.sbin/ypserv/yp_dblookup.c b/usr.sbin/ypserv/yp_dblookup.c
index 0cffdb3..76370f4 100644
--- a/usr.sbin/ypserv/yp_dblookup.c
+++ b/usr.sbin/ypserv/yp_dblookup.c
@@ -29,7 +29,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: yp_dblookup.c,v 1.7 1996/04/27 17:50:18 wpaul Exp wpaul $
+ * $Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $
*
*/
#include <stdio.h>
@@ -46,6 +46,10 @@
#include <rpcsvc/yp.h>
#include "yp_extern.h"
+#ifndef lint
+static const char rcsid[] = "$Id: yp_dblookup.c,v 1.9 1996/05/01 02:33:52 wpaul Exp $";
+#endif
+
int ypdb_debug = 0;
int yp_errno = YP_TRUE;
@@ -85,7 +89,11 @@ void yp_init_dbs()
return;
}
-static inline void yp_flush(i)
+/*
+ * Zorch a single entry in the dbent table and release
+ * all its resources.
+ */
+static __inline void yp_flush(i)
register int i;
{
(void)(dbs[i]->dbp->close)(dbs[i]->dbp);
@@ -101,8 +109,6 @@ static inline void yp_flush(i)
/*
* Close all databases and erase all database names.
- * Don't free the memory allocated for each DB entry though: we
- * can just reuse it later.
*/
void yp_flush_all()
{
@@ -122,15 +128,13 @@ void yp_flush_all()
* a new entry when all our slots are already filled, we have to kick
* out the entry in the last slot to make room.
*/
-static inline void yp_add_db(dbp, name, size)
+static __inline void yp_add_db(dbp, name, size)
DB *dbp;
char *name;
int size;
{
register int i;
register struct dbent *tmp;
- static int count = 0;
-
tmp = dbs[LASTDB];
@@ -147,15 +151,9 @@ static inline void yp_add_db(dbp, name, size)
}
/*
- * Add the new entry. We allocate memory for the dbent
- * structure if we need it. We shoudly only end up calling
- * malloc(2) MAXDB times. Once all the slots are filled, we
- * hold onto the memory and recycle it.
+ * Allocate a new entry.
*/
if (dbs[0] == NULL) {
- count++;
- if (ypdb_debug)
- yp_error("allocating new DB member (%d)", count);
dbs[0] = (struct dbent *)malloc(sizeof(struct dbent));
bzero((char *)dbs[0], sizeof(struct dbent));
}
@@ -192,9 +190,10 @@ static inline void yp_add_db(dbp, name, size)
* array so that it will be easier to find if another request for
* the same database comes in later.
*/
-static inline DB *yp_find_db(name, key, size)
+static __inline DB *yp_find_db(name, key, size)
char *name;
char *key;
+ int size;
{
register int i, j;
register struct dbent *tmp;
@@ -237,7 +236,9 @@ DB *yp_open_db_cache(domain, map, key, size)
DB *dbp = NULL;
char buf[MAXPATHLEN + 2];
- snprintf(buf, sizeof(buf), "%s/%s", domain, map);
+ strcpy(buf, domain);
+ strcat(buf, "/");
+ strcat(buf, map);
if ((dbp = yp_find_db((char *)&buf, key, size)) != NULL) {
return(dbp);
OpenPOWER on IntegriCloud