diff options
author | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-09-17 02:45:02 +0800 |
---|---|---|
committer | kcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2006-09-17 02:45:02 +0800 |
commit | 83d93227d399ba3c9a4452914fefb2d657e9218d (patch) | |
tree | 54014ffdc1ab808327f0d1a216fab0132a7bf266 /mbbsd/chat.c | |
parent | 4429dbffee0301ff16cc3a59419c61c2995b7594 (diff) | |
download | pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar.gz pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar.bz2 pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar.lz pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar.xz pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.tar.zst pttbbs-83d93227d399ba3c9a4452914fefb2d657e9218d.zip |
avoid to use gethostbyname() which require hidden memory consumption.
save near 1k memory.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3417 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/chat.c')
-rw-r--r-- | mbbsd/chat.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/mbbsd/chat.c b/mbbsd/chat.c index 8527a41f..27cd2d38 100644 --- a/mbbsd/chat.c +++ b/mbbsd/chat.c @@ -309,7 +309,6 @@ t_chat(void) char chatroom[IDLEN];/* Chat-Room Name */ char inbuf[80], chatid[20], lastcmd[MAXLASTCMD][80], *ptr = ""; struct sockaddr_in sin; - struct hostent *h; int cfd, cmdpos, ch; int currchar; int chatting = YEA; @@ -325,16 +324,12 @@ t_chat(void) memset(&chatbuf, 0, sizeof(chatbuf)); outs(" 驅車前往 請梢候........ "); - if (!(h = gethostbyname("localhost"))) { - perror("gethostbyname"); - return -1; - } memset(&sin, 0, sizeof sin); #ifdef __FreeBSD__ sin.sin_len = sizeof(sin); #endif sin.sin_family = PF_INET; - memcpy(&sin.sin_addr, h->h_addr, h->h_length); + sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); sin.sin_port = htons(NEW_CHATPORT); cfd = socket(sin.sin_family, SOCK_STREAM, 0); if (connect(cfd, (struct sockaddr *) & sin, sizeof sin) != 0) { |