Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2007-04-02 16:37:28 +0400
committerDenis Vlasenko <vda.linux@googlemail.com>2007-04-02 16:37:28 +0400
commit729bd9e0b0d5977e9c2c2a4eff7e2f0ca2ad4b9e (patch)
treed5cb1a1c7c41b2681ca867c57c3b4e473c0a56be /ipsvd/ipsvd_perhost.c
parentb05a939bcc0249fe8bd94b9795db8f8d93c3921e (diff)
test: comment out unused code
udpsvd: fake it compile tcpsvd: more optimal memorizing of IP's for -C
Diffstat (limited to 'ipsvd/ipsvd_perhost.c')
-rw-r--r--ipsvd/ipsvd_perhost.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/ipsvd/ipsvd_perhost.c b/ipsvd/ipsvd_perhost.c
index 1c5c12af5..281f708b0 100644
--- a/ipsvd/ipsvd_perhost.c
+++ b/ipsvd/ipsvd_perhost.c
@@ -22,26 +22,26 @@ void ipsvd_perhost_init(unsigned c)
cclen = c;
}
-unsigned ipsvd_perhost_add(const char *ip, unsigned maxconn, struct hcc **hccpp)
+unsigned ipsvd_perhost_add(char *ip, unsigned maxconn, struct hcc **hccpp)
{
unsigned i;
unsigned conn = 1;
- int p = -1;
+ int freepos = -1;
for (i = 0; i < cclen; ++i) {
- if (cc[i].ip[0] == 0) {
- if (p == -1) p = i;
+ if (!cc[i].ip) {
+ freepos = i;
continue;
}
- if (strncmp(cc[i].ip, ip, sizeof(cc[i].ip)) == 0) {
+ if (strcmp(cc[i].ip, ip) == 0) {
conn++;
continue;
}
}
- if (p == -1) return 0;
+ if (freepos == -1) return 0;
if (conn <= maxconn) {
- strcpy(cc[p].ip, ip);
- *hccpp = &cc[p];
+ cc[freepos].ip = ip;
+ *hccpp = &cc[freepos];
}
return conn;
}
@@ -51,7 +51,8 @@ void ipsvd_perhost_remove(int pid)
unsigned i;
for (i = 0; i < cclen; ++i) {
if (cc[i].pid == pid) {
- cc[i].ip[0] = 0;
+ free(cc[i].ip);
+ cc[i].ip = NULL;
cc[i].pid = 0;
return;
}