Jelajahi Sumber

Simplify some Array handling

Bryan Drewery 7 tahun lalu
induk
melakukan
92a070a63b
16 mengubah file dengan 100 tambahan dan 83 penghapusan
  1. 9 6
      src/adns.cc
  2. 3 2
      src/adns.h
  3. 9 11
      src/binary.cc
  4. 8 4
      src/botnet.cc
  5. 7 7
      src/chanprog.cc
  6. 10 9
      src/cmds.cc
  7. 13 11
      src/conf.cc
  8. 14 10
      src/dcc.cc
  9. 4 4
      src/libcrypto.cc
  10. 4 4
      src/libssl.cc
  11. 3 3
      src/libtcl.cc
  12. 7 5
      src/mod/irc.mod/chan.cc
  13. 2 2
      src/mod/server.mod/server.cc
  14. 4 2
      src/mod/server.mod/servmsg.cc
  15. 2 2
      src/net.cc
  16. 1 1
      src/response.cc

+ 9 - 6
src/adns.cc

@@ -1303,8 +1303,11 @@ void tell_dnsdebug(int idx)
 
 	for (int i = 0; i < ncache; i++) {
 		dprintf(idx, "cache(%d) %s expires in %ds\n", i, cache[i].query, (int) (cache[i].expiretime - now));
-		for (size_t n = 0; n < cache[i].answer->size(); n++)
-			dprintf(idx, "%zu: %s\n", n, bd::String((*(cache[i].answer))[n]).c_str());
+		size_t n = 0;
+		for (const auto& answer : *cache[i].answer) {
+			dprintf(idx, "%zu: %s\n", n, answer.c_str());
+			n++;
+		}
 	}
 }
 
@@ -1396,10 +1399,10 @@ bool valid_dns_id(int idx, int id)
 	return 0;
 }
 
-bd::String dns_find_ip(bd::Array<bd::String> ips, int af_type) {
-	for (size_t i = 0; i < ips.size(); ++i) {
-		if (is_dotted_ip(bd::String(ips[i]).c_str()) == af_type) {
-			return ips[i];
+bd::String dns_find_ip(const bd::Array<bd::String>& ips, int af_type) {
+	for (const auto& ip : ips) {
+		if (is_dotted_ip(ip.c_str()) == af_type) {
+			return ip;
 		}
 	}
 	return bd::String();

+ 3 - 2
src/adns.h

@@ -43,7 +43,8 @@ TXT             16 text strings
 #include <bdlib/src/String.h>
 #include <bdlib/src/Array.h>
 
-typedef void (*dns_callback_t)(int, void *client_data, const char *query, bd::Array<bd::String> answers);
+typedef void (*dns_callback_t)(int, void *client_data, const char *query,
+    const bd::Array<bd::String>& answers);
 
 int egg_dns_init(void);
 //int egg_dns_shutdown(void);
@@ -57,7 +58,7 @@ void tell_dnsdebug(int);
 void dns_cache_flush();
 bool valid_dns_id(int, int);
 int reverse_ip(const char *host, char *reverse);
-bd::String dns_find_ip(bd::Array<bd::String> ips, int af_type);
+bd::String dns_find_ip(const bd::Array<bd::String>& ips, int af_type);
 
 extern int		dns_sock, dns_idx;
 extern const char	*dns_ip;

+ 9 - 11
src/binary.cc

@@ -502,31 +502,29 @@ readcfg(const char *cfgfile, bool read_stdin)
 void writecfg() {
   const char salt1[] = SALT1;
   const char salt2[] = SALT2;
-  bd::Array<bd::String> owners(bd::String(settings.owners).split(","));
-  const bd::Array<bd::String> hubs(conf.hubs);
-  bd::Array<bd::String> hubInfo;
+  const auto& owners(bd::String(settings.owners).split(","));
 
   printf("PACKNAME %s\n", settings.packname);
   // Display the shellhash as salted-sha1 if it is not already
-  bd::String shellhash(settings.shellhash);
+  const bd::String shellhash(settings.shellhash);
   printf("BINARYPASS %s\n", (shellhash.length() == 40 || shellhash.length() == 47) ? shellhash.c_str() : salted_sha1(shellhash.c_str()));
   printf("DCCPREFIX %s\n", settings.dcc_prefix);
-  for (size_t i = 0; i < owners.length(); ++i) {
-    bd::Array<bd::String> ownerInfo(static_cast<bd::String>(owners[i]).split(" "));
+  for (const auto &ownerLine : owners) {
+    auto ownerInfo(ownerLine.split(" "));
     // Ensure the pass is salted-sha1
-    const size_t ownerPassLength = static_cast<bd::String>(ownerInfo[1]).length();
+    const size_t ownerPassLength = ownerInfo.at(1).length();
     if (ownerPassLength != 40 && ownerPassLength != 47) {
-      ownerInfo[1] = bd::String(salted_sha1(static_cast<bd::String>(ownerInfo[1]).c_str()));
+      ownerInfo[1] = bd::String(salted_sha1(ownerInfo.at(1).c_str()));
     }
     printf("OWNER %s\n", ownerInfo.join(" ").c_str());
   }
-  for (size_t i = 0; i < hubs.length(); ++i) {
-    hubInfo = static_cast<bd::String>(hubs[i]).split(' ');
+  for (auto hubLine : conf.hubs) {
+    auto hubInfo = hubLine.split(' ');
     // Trim away hublevel
     if (hubInfo.length() == 4) {
       hubInfo.resize(3);
     }
-    printf("HUB %s\n", static_cast<bd::String>(hubInfo.join(" ")).c_str());
+    printf("HUB %s\n", hubInfo.join(" ").c_str());
   }
   printf("SALT1 %s\n", salt1);
   printf("SALT2 %s\n", salt2);

+ 8 - 4
src/botnet.cc

@@ -994,7 +994,8 @@ int botunlink(int idx, const char *nick, const char *reason)
   return 0;
 }
 
-static void botlink_dns_callback(int, void *, const char *, bd::Array<bd::String>);
+static void botlink_dns_callback(int, void *, const char *,
+    const bd::Array<bd::String>&);
 static void botlink_real(int);
 
 /* Link to another bot
@@ -1094,7 +1095,8 @@ int botlink(char *linker, int idx, char *nick)
   return 0;
 }
 
-static void botlink_dns_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void botlink_dns_callback(int id, void *client_data, const char *host,
+    const bd::Array<bd::String>& ips)
 {
   long data = (long) client_data;
   int i = (int) data;
@@ -1207,7 +1209,8 @@ static void failed_tandem_relay(int idx)
   return;
 }
 
-static void tandem_relay_dns_callback(int, void *, const char *, bd::Array<bd::String>);
+static void tandem_relay_dns_callback(int, void *, const char *,
+    const bd::Array<bd::String>&);
 
 /* Relay to another tandembot
  */
@@ -1271,7 +1274,8 @@ void tandem_relay(int idx, char *nick, int i)
   /* wait for async reply */
 }
 
-static void tandem_relay_dns_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void tandem_relay_dns_callback(int id, void *client_data,
+    const char *host, const bd::Array<bd::String>& ips)
 {
   //64bit hacks
   long data = (long) client_data;

+ 7 - 7
src/chanprog.cc

@@ -386,15 +386,15 @@ void load_internal_users()
 
   /* hubs */
   for (size_t idx = 0; idx < conf.hubs.length(); ++idx) {
-    bd::Array<bd::String> params(static_cast<bd::String>(conf.hubs[idx]).split(' '));
-    const bd::String handle(params[0]);
-    const bd::String address(params[1]);
-    const in_port_t port = atoi(static_cast<bd::String>(params[2]).c_str());
-    const unsigned short hublevel = params.length() == 4 ? atoi(static_cast<bd::String>(params[3]).c_str()) : (idx + 1);
+    const auto& params(conf.hubs.at(idx).split(' '));
+    const auto& handle(params[0]);
+    const auto& address(params[1]);
+    const in_port_t port = atoi(params[2].c_str());
+    const unsigned short hublevel = params.length() == 4 ? atoi(params[3].c_str()) : (idx + 1);
 
-    if (!(u = get_user_by_handle(userlist, const_cast<char*>(handle.c_str())))) {
+    if (!(u = get_user_by_handle(userlist, handle.c_str()))) {
       userlist = adduser(userlist, handle.c_str(), "none", "-", USER_OP, 1);
-      u = get_user_by_handle(userlist, const_cast<char*>(handle.c_str()));
+      u = get_user_by_handle(userlist, handle.c_str());
     }
 
     simple_snprintf(tmp, sizeof(tmp), "%li [internal]", (long)now);

+ 10 - 9
src/cmds.cc

@@ -3371,7 +3371,7 @@ static void cmd_newleaf(int idx, char *par)
 
 static void cmd_newhub(int idx, char *par)
 {
-  bd::Array<bd::String> params(bd::String(par).split(' '));
+  const auto& params(bd::String(par).split(' '));
   if (!par[0] || params.length() < 3) {
     dprintf(idx, "Usage: newhub <handle> <address> <port> [hublevel]\n");
     return;
@@ -3384,7 +3384,7 @@ static void cmd_newhub(int idx, char *par)
   if (handle.length() > HANDLEN) {
     handle.resize(HANDLEN);
   }
-  if (get_user_by_handle(userlist, const_cast<char*>(handle.c_str()))) {
+  if (get_user_by_handle(userlist, handle.c_str())) {
     dprintf(idx, "Already got a %s hub\n", handle.c_str());
     return;
   } else if (strchr(BADHANDCHARS, handle[0]) != NULL) {
@@ -3392,13 +3392,13 @@ static void cmd_newhub(int idx, char *par)
     return;
   }
 
-  bd::String address(params[1]);
-  in_port_t port = atoi(static_cast<bd::String>(params[2]).c_str());
+  const auto& address(params[1]);
+  in_port_t port = atoi(params[2].c_str());
 
   unsigned short hublevel = 0;
   // Was a hublevel passed in?
   if (params.length() == 4) {
-    hublevel = atoi(static_cast<bd::String>(params[3]).c_str());
+    hublevel = atoi(params[3].c_str());
   } else {
     // Find next available hublevel
     for (struct userrec *u = userlist; u; u = u->next) {
@@ -3415,7 +3415,7 @@ static void cmd_newhub(int idx, char *par)
   char tmp[81] = "";
 
   userlist = adduser(userlist, handle.c_str(), "none", "-", USER_OP, 1);
-  u1 = get_user_by_handle(userlist, const_cast<char*>(handle.c_str()));
+  u1 = get_user_by_handle(userlist, handle.c_str());
   bi = (struct bot_addr *) calloc(1, sizeof(struct bot_addr));
   bi->uplink = (char *) calloc(1, 1);
   bi->address = strdup(address.c_str());
@@ -4310,7 +4310,8 @@ static void cmd_crontab(int idx, char *par) {
   }
 }
 
-static void my_dns_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void my_dns_callback(int id, void *client_data, const char *host,
+    const bd::Array<bd::String>& ips)
 {
   //64bit hacks
   long data = (long) client_data;
@@ -4322,8 +4323,8 @@ static void my_dns_callback(int id, void *client_data, const char *host, bd::Arr
     return;
 
   if (ips.size())
-    for (size_t i = 0; i < ips.size(); ++i)
-      dprintf(idx, "Resolved %s using (%s) to: %s\n", host, dns_ip, bd::String(ips[i]).c_str());
+    for (const auto& ip : ips)
+      dprintf(idx, "Resolved %s using (%s) to: %s\n", host, dns_ip, ip.c_str());
   else
     dprintf(idx, "Failed to lookup via (%s): %s\n", dns_ip, host);
 

+ 13 - 11
src/conf.cc

@@ -707,16 +707,18 @@ readconf(const char *fname, int bits)
 
 char s1_9[3] = "",s1_5[3] = "",s1_1[3] = "";
 
-bool hubSort (bd::String hub1, bd::String hub2) {
-  bd::Array<bd::String> hub1params(static_cast<bd::String>(hub1).split(' '));
-  bd::Array<bd::String> hub2params(static_cast<bd::String>(hub2).split(' '));
+static bool
+__attribute__((pure))
+hubSort (const bd::String& hub1, const bd::String& hub2) {
+  const auto& hub1params(hub1.split(' '));
+  const auto& hub2params(hub2.split(' '));
 
   unsigned short hub1level = 99, hub2level = 99;
   if (hub1params.length() == 4) {
-    hub1level = atoi(static_cast<bd::String>(hub1params[3]).c_str());
+    hub1level = atoi(hub1params[3].c_str());
   }
   if (hub2params.length() == 4) {
-    hub2level = atoi(static_cast<bd::String>(hub2params[3]).c_str());
+    hub2level = atoi(hub2params[3].c_str());
   }
   return hub1level < hub2level;
 }
@@ -814,10 +816,10 @@ writeconf(char *filename, int fd, int bits)
     bd::Array<bd::String> sortedhubs(conf.hubs);
     std::sort(sortedhubs.begin(), sortedhubs.end(), hubSort);
 
-    for (size_t idx = 0; idx < sortedhubs.length(); ++idx) {
-      bd::Array<bd::String> hubparams(static_cast<bd::String>(sortedhubs[idx]).split(' '));
-      bd::String hubnick(hubparams[0]), address(hubparams[1]);
-      in_port_t port = atoi(static_cast<bd::String>(hubparams[2]).c_str());
+    for (const auto& hubLine : sortedhubs) {
+      const auto& hubparams(hubLine.split(' '));
+      const auto& hubnick(hubparams[0]), address(hubparams[1]);
+      const in_port_t port = atoi(hubparams[2].c_str());
       *stream << bd::String::printf(STR("! hub %s %s %d\n"), hubnick.c_str(), address.c_str(), port);
     }
     comment("");
@@ -1045,8 +1047,8 @@ void conf_update_hubs(struct userrec* list) {
 
   conf.hubs.clear();
   conf.hubs.Reserve(hubUsers.length());
-  for (size_t idx = 0; idx < hubUsers.length(); ++idx) {
-    struct userrec *u = get_user_by_handle(list, const_cast<char*>(static_cast<bd::String>(hubUsers[idx]).c_str()));
+  for (const auto& hubUser : hubUsers) {
+    struct userrec *u = get_user_by_handle(list, hubUser.c_str());
     struct bot_addr *bi = (struct bot_addr *) get_user(&USERENTRY_BOTADDR, u);
     conf.hubs << bd::String::printf("%s %s %d %d", u->handle, bi->address, bi->telnet_port, bi->hublevel);
   }

+ 14 - 10
src/dcc.cc

@@ -1403,8 +1403,10 @@ detect_telnet_flood(char *floodhost)
   return 0;
 }
 
-static void dcc_telnet_dns_callback(int, void *, const char *, bd::Array<bd::String>);
-static void dcc_telnet_dns_forward_callback(int, void *, const char *, bd::Array<bd::String>);
+static void dcc_telnet_dns_callback(int, void *, const char *,
+    const bd::Array<bd::String>&);
+static void dcc_telnet_dns_forward_callback(int, void *, const char *,
+    const bd::Array<bd::String>&);
 
 static void
 dcc_telnet(int idx, char *buf, int ii)
@@ -1499,7 +1501,8 @@ dcc_telnet(int idx, char *buf, int ii)
     dcc[i].dns_id = dns_id;
 }
 
-static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip, bd::Array<bd::String> hosts)
+static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip,
+    const bd::Array<bd::String>& hosts)
 {
   // 64bit hacks
   long data = (long) client_data;
@@ -1525,23 +1528,24 @@ static void dcc_telnet_dns_callback(int id, void *client_data, const char *ip, b
   //Clear the ip (still saved in dcc[i].addr)
   dcc[i].host[0] = 0;
   if (hosts.size()) {
-    strlcpy(dcc[i].host, bd::String(hosts[0]).c_str(), sizeof(dcc[i].host));
+    strlcpy(dcc[i].host, hosts[0].c_str(), sizeof(dcc[i].host));
 
     //Check forward; only check the protocol of which this connection is.
     //If they connected on V4, lookup A, if V6, lookup AAAA
     int dns_type = DNS_LOOKUP_A;
     if (is_dotted_ip(iptostr(htonl(dcc[i].addr))) == AF_INET6)//Is this even valid?
       dns_type = DNS_LOOKUP_AAAA;
-    int dns_id = egg_dns_lookup(bd::String(hosts[0]).c_str(), 20, dcc_telnet_dns_forward_callback, (void *) (long) i, dns_type);
+    int dns_id = egg_dns_lookup(hosts[0].c_str(), 20, dcc_telnet_dns_forward_callback, (void *) (long) i, dns_type);
     if (dns_id >= 0)
       dcc[i].dns_id = dns_id;
   } else {
-    bd::Array<bd::String> empty;
+    const bd::Array<bd::String> empty;
     dcc_telnet_dns_forward_callback(id, client_data, ip, empty);
   }
 }
 
-static void dcc_telnet_dns_forward_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips) {
+static void dcc_telnet_dns_forward_callback(int id, void *client_data,
+    const char *host, const bd::Array<bd::String>& ips) {
   // 64bit hacks
   long data = (long) client_data;
   int i = (int) data;
@@ -1565,10 +1569,10 @@ static void dcc_telnet_dns_forward_callback(int id, void *client_data, const cha
   }
 
   bool forward_matched = false;
-  bd::String look_for_ip(iptostr(htonl(dcc[i].addr)));
+  const auto& look_for_ip(iptostr(htonl(dcc[i].addr)));
   // Look for any match
-  for (size_t n = 0; n < ips.size(); ++n) {
-    if (ips[n] == look_for_ip) {
+  for (const auto& ip : ips) {
+    if (ip == look_for_ip) {
       forward_matched = true;
       break;
     }

+ 4 - 4
src/libcrypto.cc

@@ -101,13 +101,13 @@ int load_libcrypto() {
 
   sdprintf("Loading libcrypto");
 
-  bd::Array<bd::String> libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.1.1 libcrypto.so.1.0.0 libcrypto.so.0.9.8 libcrypto.so.10 libcrypto.so.9 libcrypto.so.8 libcrypto.so.7 libcrypto.so.6").split(' '));
+  const auto& libs_list(bd::String("libcrypto.so." SHLIB_VERSION_NUMBER " libcrypto.so libcrypto.so.1.1 libcrypto.so.1.0.0 libcrypto.so.0.9.8 libcrypto.so.10 libcrypto.so.9 libcrypto.so.8 libcrypto.so.7 libcrypto.so.6").split(' '));
 
-  for (size_t i = 0; i < libs_list.length(); ++i) {
+  for (const auto& lib : libs_list) {
     dlerror(); // Clear Errors
-    libcrypto_handle = dlopen(bd::String(libs_list[i]).c_str(), RTLD_LAZY|RTLD_GLOBAL);
+    libcrypto_handle = dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
     if (libcrypto_handle) {
-      sdprintf("Found libcrypto: %s", bd::String(libs_list[i]).c_str());
+      sdprintf("Found libcrypto: %s", lib.c_str());
       break;
     }
   }

+ 4 - 4
src/libssl.cc

@@ -82,13 +82,13 @@ int load_libssl() {
 
   sdprintf("Loading libssl");
 
-  bd::Array<bd::String> libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.1.1 libssl.so.1.0.0 libssl.so.0.9.8 libssl.so.10 libssl.so.9 libssl.so.8 libssl.so.7 libssl.so.6").split(' '));
+  const auto& libs_list(bd::String("libssl.so." SHLIB_VERSION_NUMBER " libssl.so libssl.so.1.1 libssl.so.1.0.0 libssl.so.0.9.8 libssl.so.10 libssl.so.9 libssl.so.8 libssl.so.7 libssl.so.6").split(' '));
 
-  for (size_t i = 0; i < libs_list.length(); ++i) {
+  for (const auto& lib : libs_list) {
     dlerror(); // Clear Errors
-    libssl_handle = dlopen(bd::String(libs_list[i]).c_str(), RTLD_LAZY);
+    libssl_handle = dlopen(lib.c_str(), RTLD_LAZY);
     if (libssl_handle) {
-      sdprintf("Found libssl: %s", bd::String(libs_list[i]).c_str());
+      sdprintf("Found libssl: %s", lib.c_str());
       break;
     }
   }

+ 3 - 3
src/libtcl.cc

@@ -67,11 +67,11 @@ int load_libtcl() {
   }
 #endif
 
-  bd::Array<bd::String> libs_list(bd::String("libtcl.so libtcl83.so libtcl8.3.so libtcl84.so libtcl8.4.so libtcl85.so libtcl8.5.so libtcl86.so libtcl8.6.so").split(' '));
+  const auto& libs_list(bd::String("libtcl.so libtcl83.so libtcl8.3.so libtcl84.so libtcl8.4.so libtcl85.so libtcl8.5.so libtcl86.so libtcl8.6.so").split(' '));
 
-  for (size_t i = 0; i < libs_list.length(); ++i) {
+  for (const auto& lib : libs_list) {
     dlerror(); // Clear Errors
-    libtcl_handle = dlopen(bd::String(libs_list[i]).c_str(), RTLD_LAZY);
+    libtcl_handle = dlopen(lib.c_str(), RTLD_LAZY);
     if (libtcl_handle) break;
   }
   if (!libtcl_handle) {

+ 7 - 5
src/mod/irc.mod/chan.cc

@@ -44,7 +44,8 @@ typedef struct resolvstruct {
   bd::String* server;
 } resolv_member;
 
-static void resolv_member_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void resolv_member_callback(int id, void *client_data, const char *host,
+    const bd::Array<bd::String>& ips)
 {
   resolv_member *r = (resolv_member *) client_data;
   struct chanset_t* chan = NULL;
@@ -68,7 +69,7 @@ static void resolv_member_callback(int id, void *client_data, const char *host,
       pe = strchr(m->userhost, '@');
       if (pe && !strcmp(pe + 1, r->host)) {
         strlcpy(user, m->userhost, pe - m->userhost + 1);
-        simple_snprintf(m->userip, sizeof(m->userip), "%s@%s", user, bd::String(ips[0]).c_str());
+        simple_snprintf(m->userip, sizeof(m->userip), "%s@%s", user, ips[0].c_str());
         simple_snprintf(m->fromip, sizeof(m->fromip), "%s!%s", m->nick, m->userip);
         if (!m->user) {
           m->user = get_user_by_host(m->fromip);
@@ -84,7 +85,7 @@ static void resolv_member_callback(int id, void *client_data, const char *host,
   }
 
   if (!matched_user && channel_rbl(chan))
-    resolve_to_rbl(chan, bd::String(ips[0]).c_str());
+    resolve_to_rbl(chan, ips[0].c_str());
 
   free(r->host);
   free(r->chan);
@@ -110,7 +111,8 @@ void resolve_to_member(struct chanset_t *chan, char *nick, char *host)
 }
 
 /* RBL */
-static void resolve_rbl_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void resolve_rbl_callback(int id, void *client_data, const char *host,
+    const bd::Array<bd::String>& ips)
 {
   resolv_member *r = (resolv_member *) client_data;
   struct chanset_t* chan = NULL;
@@ -123,7 +125,7 @@ static void resolve_rbl_callback(int id, void *client_data, const char *host, bd
     return;
   }
 
-  sdprintf("RBL match for %s:%s: %s", chan->dname, r->host, bd::String(ips[0]).c_str());
+  sdprintf("RBL match for %s:%s: %s", chan->dname, r->host, ips[0].c_str());
 
   char s1[UHOSTLEN] = "";
   simple_snprintf(s1, sizeof(s1), "*!*@%s", r->host);

+ 2 - 2
src/mod/server.mod/server.cc

@@ -178,8 +178,8 @@ burst_mode_ok(const char *msg, size_t len) {
   const auto list(mode.split(' '));
   if (list.length() == 2) return 1;
   if (list.length() == 3) {
-    if (!strchr(CHANMETA, bd::String(list[1]).at(0))) return 1;
-    else if (bd::String(list[2]).at(0) == 'b') return 1;
+    if (!strchr(CHANMETA, list[1][0])) return 1;
+    else if (list[2][0] == 'b') return 1;
   }
   return 0;
 }

+ 4 - 2
src/mod/server.mod/servmsg.cc

@@ -2043,7 +2043,8 @@ static cmd_t my_raw_binds[] =
   {NULL,	NULL,	NULL,				NULL, 0}
 };
 
-static void server_dns_callback(int, void *, const char *, bd::Array<bd::String>);
+static void server_dns_callback(int, void *, const char *,
+    const bd::Array<bd::String>&);
 
 /* Hook up to a server
  */
@@ -2122,7 +2123,8 @@ static void connect_server(void)
   }
 }
 
-static void server_dns_callback(int id, void *client_data, const char *host, bd::Array<bd::String> ips)
+static void server_dns_callback(int id, void *client_data, const char *host,
+    const bd::Array<bd::String>& ips)
 {
   //64bit hacks
   long data = (long) client_data;

+ 2 - 2
src/net.cc

@@ -119,12 +119,12 @@ static int get_ip(char *hostname, union sockaddr_union *so, int dns_type)
   memset(so, 0, sizeof(union sockaddr_union));
   debug1("get_ip(%s)", hostname);
 
-  bd::Array<bd::String> hosts = dns_lookup_block(hostname, 10, dns_type);
+  const auto& hosts = dns_lookup_block(hostname, 10, dns_type);
   if (hosts.length() == 0)
     return -1;
 
   my_addr_t addr;
-  get_addr(bd::String(hosts[0]).c_str(), &addr);
+  get_addr(hosts[0].c_str(), &addr);
 
   if (addr.family == AF_INET) {
     so->sin.sin_family = AF_INET;

+ 1 - 1
src/response.cc

@@ -25,6 +25,6 @@ init_responses()
 const char *
 response(response_t type)
 {
-  return res_map[type].at(randint(res_map[type].size()));
+  return res_map[type][randint(res_map[type].size())];
 }
 /* vim: set sts=2 sw=2 ts=8 et: */