delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/09/03/01:28:21

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <006101c2530a$aac39d00$0202a8c0@serge>
From: "Serge P. Voronin" <buddie AT rambler DOT ru>
To: <cygwin AT cygwin DOT com>
Subject: memory leak in gethostbyaddr() ?
Date: Tue, 3 Sep 2002 11:27:58 +0600
MIME-Version: 1.0
X-Priority: 3
X-MSMail-Priority: Normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
Note-from-DJ: This may be spam

------=_NextPart_000_005E_01C2533C.F4A3BDB0
Content-Type: text/plain;
	charset="koi8-r"
Content-Transfer-Encoding: 7bit

Hi!

    I'm use gethostbyaddr() for name resolving. But when I'm call
gethostbyaddr() many times, the memory, allocated by the program is growing
(see attach). Why?

--
Best regards, Serge P. Voronin
St.Ingineer of NDT, JSC "Tekhdiagnostika", Orenburg, Russia
tel. +7-(3532)-631166, fax. +7-(3532)-629441
mailto:buddie AT rambler DOT ru


------=_NextPart_000_005E_01C2533C.F4A3BDB0
Content-Type: application/octet-stream;
	name="testgethostbyaddr.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="testgethostbyaddr.c"

#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>

#define	COUNT	100000


int main(void)
{
	int		i;
	struct in_addr	addr;
	struct hostent	*hp;

	addr.s_addr = htonl(INADDR_LOOPBACK);

	for (i = 0; i < COUNT; i++)
	{
		hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET);
		if (hp)
			printf("%d: %s = %s\n", i, inet_ntoa(addr), hp->h_name);
		else
			printf("%d: Resolving failed\n", i);
	}

 	return 0;
}

------=_NextPart_000_005E_01C2533C.F4A3BDB0
Content-Type: text/plain; charset=us-ascii

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/
------=_NextPart_000_005E_01C2533C.F4A3BDB0--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019