Browse Source

Fixup struct _res handling so apps using struct _res can actually
compile ("worst standard ever!")
-Erik

Eric Andersen 22 years ago
parent
commit
bfefdc6565
2 changed files with 4 additions and 14 deletions
  1. 2 3
      include/resolv.h
  2. 2 11
      libc/inet/resolv.c

+ 2 - 3
include/resolv.h

@@ -216,12 +216,11 @@ typedef struct __res_state *res_state;
 #define RES_PRF_INIT	0x00004000
 /*			0x00008000	*/
 
-
-#ifndef __BIND_NOSTATIC
-
 /* Internal (static) resolver context. */
 extern struct __res_state _res;
 
+#ifndef __BIND_NOSTATIC
+
 #define fp_nquery		__fp_nquery
 #define fp_query		__fp_query
 #define hostalias		__hostalias

+ 2 - 11
libc/inet/resolv.c

@@ -967,16 +967,11 @@ struct netent * getnetbyname(const char * name)
 
 
 #ifdef L_res_init
-struct __res_state * __res;
+struct __res_state _res;
 
 int res_init(void)
 {
-	struct __res_state *rp = __res;
-	if(!__res) {
-		rp = (struct __res_state *) malloc(sizeof(struct __res_state));
-		memset(rp, 0, sizeof(struct __res_state));
-		__res = rp;
-	}	
+	struct __res_state *rp = &(_res);
 
 	__open_nameservers();
 	rp->retrans = RES_TIMEOUT;
@@ -1021,10 +1016,6 @@ int res_init(void)
 
 void res_close( void )
 {
-	if(__res) {
-		free(__res);
-		__res = NULL;
-	}
 	return;
 }