]> git.meshlink.io Git - catta/blobdiff - avahi-daemon/static-services.c
* Update TODO
[catta] / avahi-daemon / static-services.c
index d4198c44ca9fdccd5357112cde8eb7b2c7590d91..e402a9853de94b07c70118e340b5d25554718282 100644 (file)
@@ -35,6 +35,8 @@
 
 #include <avahi-common/llist.h>
 #include <avahi-common/malloc.h>
+#include <avahi-common/alternative.h>
+#include <avahi-common/error.h>
 #include <avahi-core/log.h>
 
 #include "main.h"
@@ -199,14 +201,15 @@ static void add_static_service_group_to_server(StaticServiceGroup *g) {
         /* This service group is already registered in the server */
         return;
     
-    if (g->chosen_name)
-        avahi_free(g->chosen_name);
-    
-    if (g->replace_wildcards)
-        g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
-    else
-        g->chosen_name = avahi_strdup(g->name);
+    if (!g->chosen_name) {
+        
+        if (g->replace_wildcards)
+            g->chosen_name = replacestr(g->name, "%h", avahi_server_get_host_name(avahi_server));
+        else
+            g->chosen_name = avahi_strdup(g->name);
 
+    }
+        
     if (!g->entry_group)
         g->entry_group = avahi_s_entry_group_new(avahi_server, entry_group_callback, g);
 
@@ -395,7 +398,7 @@ static void XMLCALL xml_end(void *data, const char *el) {
             int protocol;
             assert(u->service);
 
-            if (u->buf & &strcasecmp (u->buf, "ipv4") == 0) {
+            if (u->buf &strcasecmp (u->buf, "ipv4") == 0) {
                 protocol = AVAHI_PROTO_INET;
             } else if (u->buf && strcasecmp (u->buf, "ipv6") == 0) {
                 protocol = AVAHI_PROTO_INET6;