From b3ec30bf27d9da41586a4b8cfb28e5f7430a84e1 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Fri, 25 May 2012 15:02:54 +0000 Subject: [PATCH] Corrigindo memory leak --- Makefile.in | 2 +- host.c | 8 +++++--- testprogram.c | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Makefile.in b/Makefile.in index 87147ed..59d0e11 100644 --- a/Makefile.in +++ b/Makefile.in @@ -127,7 +127,7 @@ $(BINRLS)/@DLLPREFIX@3270@DLLEXT@: $(foreach SRC, $(basename $(SOURCES)), $(OBJR $(BINDBG)/testprogram$(EXEEXT): $(OBJDBG)/testprogram.o $(foreach SRC, $(basename $(SOURCES)), $(OBJDBG)/$(SRC)@OBJEXT@) @echo " CCLD `basename $@`" @$(MKDIR) `dirname $@` - $(LD) -o $@ $^ $(LIBS) + $(LD) -pthread -o $@ $^ $(LIBS) $(DEBDIR)/lib3270.install: Makefile @echo " GEN `basename $@`" diff --git a/host.c b/host.c index f0e1b37..f900479 100644 --- a/host.c +++ b/host.c @@ -474,9 +474,9 @@ split_success: static int do_connect(H3270 *hSession, const char *n) { - char nb[2048]; /* name buffer */ - char *s; /* temporary */ - const char *chost; /* to whom we will connect */ + char nb[2048]; /* name buffer */ + char *s; /* temporary */ + char *chost = NULL; /* to whom we will connect */ // char *ps = CN; char *port = CN; Boolean resolving; @@ -555,6 +555,8 @@ static int do_connect(H3270 *hSession, const char *n) return -1; } + chost = lib3270_free(chost); + /* Still thinking about it? */ if (resolving) { diff --git a/testprogram.c b/testprogram.c index 7e4d760..9673a5d 100644 --- a/testprogram.c +++ b/testprogram.c @@ -33,6 +33,7 @@ int main(int numpar, char *param[]) printf("3270 session %p created\n]",h); pthread_create(&thread, NULL, mainloop, NULL); + pthread_detach(thread); while(fgets(line,4095,stdin)) { -- libgit2 0.21.2