chiark / gitweb /
cleanup: All the whitespace fixes, all at once.
[mLib] / bres-adns.c
index 34372a9cda03fbae818548a15b394f172e984162..0679207c23b32e2c42e97b8e68ec6482d43f3ef1 100644 (file)
@@ -1,13 +1,13 @@
 /* -*-c-*-
  *
- * $Id: bres-adns.c,v 1.3 2004/04/03 03:28:54 mdw Exp $
+ * $Id$
  *
  * Background reverse name resolution (ADNS version)
  *
  * (c) 2003 Straylight/Edgeware
  */
 
-/*----- Licensing notice --------------------------------------------------* 
+/*----- Licensing notice --------------------------------------------------*
  *
  * This file is part of the mLib utilities library.
  *
  * it under the terms of the GNU Library General Public License as
  * published by the Free Software Foundation; either version 2 of the
  * License, or (at your option) any later version.
- * 
+ *
  * mLib is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU Library General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Library General Public
  * License along with mLib; if not, write to the Free
  * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
  * must be licensed under the full GPL.
  */
 
-/*----- Revision history --------------------------------------------------* 
- *
- * $Log: bres-adns.c,v $
- * Revision 1.3  2004/04/03 03:28:54  mdw
- * Make ADNS wait for the event loop before collecting replies.
- *
- * Revision 1.2  2003/12/14 14:46:38  mdw
- * Qualify name given to @bres_byname@.
- *
- * Revision 1.1  2003/12/13 20:37:59  mdw
- * Add adns support in background resolver.
- *
- */
-
 #ifndef HAVE_ADNS
 #  error "You need the ADNS library to compile this file."
 #endif
@@ -241,7 +227,7 @@ static void report(bres_client *rc, adns_answer *a,
   h.h_addrtype = AF_INET;
   h.h_length = sizeof(struct in_addr);
   h.h_addr_list = aa;
-  rc->func(&h, rc->p);  
+  rc->func(&h, rc->p);
 }
 
 /* --- @beforehook@, @afterhook@ --- *
@@ -268,7 +254,7 @@ static void afterhook(sel_state *s, sel_args *sa, void *p)
   void *c;
   bres_client *rc;
   adns_query q;
-  adns_answer *a;
+  adns_answer *a, *aa;
   int e;
   int i;
 
@@ -282,8 +268,8 @@ static void afterhook(sel_state *s, sel_args *sa, void *p)
     else switch (rc->q) {
       case adns_r_addr:
        assert(a->type == adns_r_addr);
+       xfree(rc->u.name);
        report(rc, a, a->rrs.addr, a->nrrs, &a->owner, 1);
-       free(rc->u.name);
        free(a);
        break;
       case adns_r_ptr:
@@ -303,8 +289,9 @@ static void afterhook(sel_state *s, sel_args *sa, void *p)
          }
          goto fail;
        match:
-         report(rc, a, &a->rrs.addr[i], 1, rc->a->rrs.str, rc->a->nrrs);
-         free(rc->a);
+         aa = rc->a;
+         report(rc, a, &a->rrs.addr[i], 1, aa->rrs.str, aa->nrrs);
+         free(aa);
          free(a);
        }
        break;
@@ -314,9 +301,9 @@ static void afterhook(sel_state *s, sel_args *sa, void *p)
     continue;
 
   fail:
-    rc->func(0, rc->p);
     if (rc->q == adns_r_addr) xfree(rc->u.name);
     if (rc->a) free(rc->a);
+    rc->func(0, rc->p);
     free(a);
   }
 }