diff src/protocols/rendezvous/mdns_cache.c @ 8806:8212661dc3cc

[gaim-migrate @ 9568] I think mDNS records should be caching now... my iBook isn't booting, so I don't really have a way to test it. I need to fix that. I change some stuff from GHashTables to GSLists, I think, which meant changing a lot of code. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 25 Apr 2004 16:23:20 +0000
parents dbbf5470ba05
children beb7be215db3
line wrap: on
line diff
--- a/src/protocols/rendezvous/mdns_cache.c	Sun Apr 25 13:54:49 2004 +0000
+++ b/src/protocols/rendezvous/mdns_cache.c	Sun Apr 25 16:23:20 2004 +0000
@@ -28,38 +28,46 @@
 
 #include "mdns.h"
 
-GSList *resourcerecords = NULL;
+/* XXX - Make sure this is freed when we sign off */
+GSList *rrs = NULL;
+
+void
+mdns_cache_add(const ResourceRecord *rr)
+{
+	ResourceRecord *new;
 
-void mdns_cache_add(ResourceRecord *rr)
+	g_return_if_fail(rr != NULL);
+
+	new = mdns_copy_rr(rr);
+
+	rrs = g_slist_prepend(rrs, new);
+}
+
+void
+mdns_cache_remove(ResourceRecord *rr)
 {
 	g_return_if_fail(rr != NULL);
 
-	resourcerecords = g_slist_prepend(resourcerecords, rr);
-}
-
-void mdns_cache_remove(ResourceRecord *rr)
-{
-	g_return_if_fail(rr != NULL);
-
-	resourcerecords = g_slist_remove_all(resourcerecords, rr);
+	rrs = g_slist_remove_all(rrs, rr);
 
 	mdns_free_rr(rr);
 }
 
-void mdns_cache_remove_all()
+void
+mdns_cache_remove_all()
 {
-	while (resourcerecords != NULL)
-		mdns_cache_remove(resourcerecords->data);
+	mdns_free_rrs(rrs);
 }
 
-void mdns_cache_respond(int fd, Question *q)
+void
+mdns_cache_respond(int fd, const Question *q)
 {
 	GSList *slist;
 	ResourceRecord *cur;
 
 	g_return_if_fail(q != NULL);
 
-	for (slist = resourcerecords; slist != NULL; slist = g_slist_next(slist)) {
+	for (slist = rrs; slist != NULL; slist = g_slist_next(slist)) {
 		cur = slist->data;
 		if ((q->type == cur->type) && (!strcmp(q->name, cur->name)))
 			mdns_send_rr(fd, cur);