summaryrefslogtreecommitdiff
path: root/source3/nmbd/nmbd_subnetdb.c
diff options
context:
space:
mode:
authorChristopher R. Hertel <crh@samba.org>1998-06-10 19:51:58 +0000
committerChristopher R. Hertel <crh@samba.org>1998-06-10 19:51:58 +0000
commitd4366df039dfd730fe24c95b9ef7d59306f35309 (patch)
treed872bd4ba5aa2aabecadf8d71382ba758aa00928 /source3/nmbd/nmbd_subnetdb.c
parent72bf410b6e9b85f8fbff7f6175661829bef35f62 (diff)
downloadsamba-d4366df039dfd730fe24c95b9ef7d59306f35309.tar.gz
I've replaced the linked list used to manage the subnet namelists with a
splay tree. For short lists, this will have no noticable effect. As lists (eg. the WINS database) grow longer, the speed improvements should be quite dramatic. This change is an incremental step toward replacing the in-memory namelists with a back-end database. This change is going into the 1.9.19pre-alpha code because...well...it's pre-alpha. Please let me know if there are any problems. (Oh, as a side-effect, the wins.dat will be in sorted order. :) Chris -)----- (This used to be commit 7806c453df02a89f67e7c5c8b91f24aa2274e756)
Diffstat (limited to 'source3/nmbd/nmbd_subnetdb.c')
-rw-r--r--source3/nmbd/nmbd_subnetdb.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source3/nmbd/nmbd_subnetdb.c b/source3/nmbd/nmbd_subnetdb.c
index 34287bbe699..2b29d1b45ba 100644
--- a/source3/nmbd/nmbd_subnetdb.c
+++ b/source3/nmbd/nmbd_subnetdb.c
@@ -73,6 +73,17 @@ static void add_subnet(struct subnet_record *subrec)
subrec->prev = subrec2;
}
+/* CRH!!! */
+/* ************************************************************************** ** * This will go away when we move to a "real" database back-end.
+ * ************************************************************************** ** */
+int namelist_entry_compare( ubi_trItemPtr Item, ubi_trNodePtr Node )
+ {
+ struct name_record *NR = (struct name_record *)Node;
+
+ return( memcmp( Item, &(NR->name), sizeof(struct nmb_name) ) );
+ } /* namelist_entry_compare */
+/* CRH!!! */
+
/****************************************************************************
Create a subnet entry.
****************************************************************************/
@@ -131,8 +142,11 @@ for port %d. Error was %s\n", inet_ntoa(myip), DGRAM_PORT, strerror(errno)));
return(NULL);
}
- bzero((char *)subrec,sizeof(*subrec));
-
+ bzero( (char *)subrec, sizeof(*subrec) );
+ (void)ubi_trInitTree( subrec->namelist,
+ namelist_entry_compare,
+ ubi_trOVERWRITE );
+
if((subrec->subnet_name = strdup(name)) == NULL)
{
DEBUG(0,("make_subnet: malloc fail for subnet name !\n"));