Replace `name_reinit' by `name_end' for more sensible restart.
authormdw <mdw>
Wed, 20 Aug 1997 16:19:24 +0000 (16:19 +0000)
committermdw <mdw>
Wed, 20 Aug 1997 16:19:24 +0000 (16:19 +0000)
src/name.c
src/name.h
src/netg.h

index aaf7491..02e0241 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: name.c,v 1.3 1997/08/07 09:49:39 mdw Exp $
+ * $Id: name.c,v 1.4 1997/08/20 16:17:59 mdw Exp $
  *
  * Looking up of names in symbol tables
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: name.c,v $
+ * Revision 1.4  1997/08/20 16:17:59  mdw
+ * Replace `name_reinit' by `name_end' for more sensible restart.
+ *
  * Revision 1.3  1997/08/07 09:49:39  mdw
  * Extensive modifications to handle netgroups.  Also sanitise user and group
  * names before adding them to the symbol table.
@@ -155,8 +158,6 @@ static void name__users(void)
     name *n;
     int u = pw->pw_uid;
 
-    /* --- Make the name into something nice --- */
-
     /* --- First, add the user to the table --- */
 
     if (name__sanitise(pw->pw_name, buf, sizeof(buf)) &&
@@ -369,18 +370,17 @@ void name_init(void)
   }
 }
 
-/* --- @name_reinit@ --- *
+/* --- @name_end@ --- *
  *
  * Arguments:  ---
  *
  * Returns:    ---
  *
- * Use:                Reinitialises the names table.  It's cleared and then
- *             initialised with the current user and group ids as for
- *             @name_init@ above.
+ * Use:                Closes down the name database, so that it can be
+ *             reinitialised.
  */
 
-void name_reinit(void)
+void name_end(void)
 {
   /* --- Empty the symbol table --- */
 
@@ -397,7 +397,6 @@ void name_reinit(void)
   /* --- Destroy and recreate the table --- */
 
   sym_destroyTable(&name__table);
-  name_init();
 }
 
 /* --- @name_find@ --- *
@@ -432,6 +431,7 @@ name *name_find(const char *p, unsigned create, unsigned *f)
 
 void name_dump(void)
 {
+#ifdef TRACING
   sym_iter i;
   name *n;
 
@@ -440,6 +440,7 @@ void name_dump(void)
     trace(TRACE_DEBUG, "name: dumping `%s'", n->base.name);
     class_dump(n->c);
   }
+#endif
 }  
 
 /*----- Test driver -------------------------------------------------------*/
@@ -449,13 +450,28 @@ void name_dump(void)
 int main(void)
 {
   ego("name-test");
-  traceon(stdout, TRACE_ALL);
+  /* traceon(stdout, TRACE_ALL); */
   userdb_init();
   userdb_local();
   userdb_yp();
   netg_init();
   name_init();
-  name_dump();
+  printf("loaded (%lu)\n", track_memused());
+  getchar();
+  for (;;) {
+    name_end();
+    netg_end();
+    userdb_end();
+    printf("cleared (%lu)\n", track_memused());
+    track_memlist();
+    userdb_init();
+    userdb_local();
+    userdb_yp();
+    netg_init();
+    name_init();
+    printf("reloaded (%lu)\n", track_memused());
+    getchar();
+  }
   return (0);
 }
 
index 93793c9..85e170e 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: name.h,v 1.2 1997/08/04 10:24:24 mdw Exp $
+ * $Id: name.h,v 1.3 1997/08/20 16:18:05 mdw Exp $
  *
  * Looking up of names in symbol tables
  *
@@ -29,6 +29,9 @@
 /*----- Revision history --------------------------------------------------*
  *
  * $Log: name.h,v $
+ * Revision 1.3  1997/08/20 16:18:05  mdw
+ * Replace `name_reinit' by `name_end' for more sensible restart.
+ *
  * Revision 1.2  1997/08/04 10:24:24  mdw
  * Sources placed under CVS control.
  *
@@ -75,18 +78,17 @@ typedef struct name {
 
 extern void name_init(void);
 
-/* --- @name_reinit@ --- *
+/* --- @name_end@ --- *
  *
  * Arguments:  ---
  *
  * Returns:    ---
  *
- * Use:                Reinitialises the names table.  It's cleared and then
- *             initialised with the current user and group ids as for
- *             @name_init@ above.
+ * Use:                Closes down the name database, so that it can be
+ *             reinitialised.
  */
 
-extern void name_reinit(void);
+extern void name_end(void);
 
 /* --- @name_find@ --- *
  *
index 964acb6..79a49e9 100644 (file)
@@ -1,6 +1,6 @@
 /* -*-c-*-
  *
- * $Id: netg.h,v 1.1 1997/08/07 09:45:00 mdw Exp $
+ * $Id: netg.h,v 1.2 1997/08/20 16:19:24 mdw Exp $
  *
  * A local database of netgroups
  *
@@ -29,6 +29,9 @@
  /*----- Revision history --------------------------------------------------*
  *
  * $Log: netg.h,v $
+ * Revision 1.2  1997/08/20 16:19:24  mdw
+ * Replace `name_reinit' by `name_end' for more sensible restart.
+ *
  * Revision 1.1  1997/08/07 09:45:00  mdw
  * New source file added to maintain a netgroups database.
  *
@@ -128,16 +131,16 @@ extern int netg_scan(netg */*n*/,
 
 extern void netg_init(void);
 
-/* --- @netg_reinit@ --- *
+/* --- @netg_end@ --- *
  *
  * Arguments:  ---
  *
  * Returns:    ---
  *
- * Use:                Forces a re-read of the netgroups file.
+ * Use:                Empties the netgroups database.
  */
 
-extern void netg_reinit(void);
+extern void netg_end(void);
 
 /*----- That's all, folks -------------------------------------------------*/