summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--cursor.c2
-rw-r--r--example.c18
-rw-r--r--main.c16
-rw-r--r--rfbserver.c4
5 files changed, 38 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 8d5e187..8767a12 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+ memory leaks squashed (localtime pseudo leak is still there :-)
+ small improvements for OSXvnc (still not working correctly)
synced with TightVNC 1.2.3
solaris compile cleanups
many x11vnc improvements
diff --git a/cursor.c b/cursor.c
index 057ff5e..bf2167d 100644
--- a/cursor.c
+++ b/cursor.c
@@ -272,6 +272,8 @@ char* rfbMakeMaskForXCursor(int width,int height,char* source)
void rfbFreeCursor(rfbCursorPtr cursor)
{
if(cursor) {
+ if(cursor->richSource)
+ free(cursor->richSource);
free(cursor->source);
free(cursor->mask);
free(cursor);
diff --git a/example.c b/example.c
index 41165c7..01ec504 100644
--- a/example.c
+++ b/example.c
@@ -262,6 +262,17 @@ int main(int argc,char** argv)
/* initialize the server */
rfbInitServer(rfbScreen);
+#define USE_OWN_LOOP
+#ifdef USE_OWN_LOOP
+ {
+ int i;
+ for(i=0;i<200;i++) {
+ fprintf(stderr,"%d\r",i);
+ rfbProcessEvents(rfbScreen,100000);
+ }
+ }
+#else
+
#ifndef BACKGROUND_LOOP_TEST
/* this is the blocking event loop, i.e. it never returns */
/* 40000 are the microseconds, i.e. 0.04 seconds */
@@ -274,6 +285,11 @@ int main(int argc,char** argv)
rfbRunEventLoop(rfbScreen,-1,TRUE);
/* now we could do some cool things like rendering */
while(1) sleep(5); /* render(); */
-
+#endif
+
+ rfbFreeCursor(rfbScreen->cursor);
+ free(rfbScreen->frameBuffer);
+ rfbScreenCleanup(rfbScreen);
+
return(0);
}
diff --git a/main.c b/main.c
index c9f8f85..b534ea3 100644
--- a/main.c
+++ b/main.c
@@ -55,7 +55,7 @@ rfbLog(const char *format, ...)
time(&log_clock);
strftime(buf, 255, "%d/%m/%Y %T ", localtime(&log_clock));
- fprintf(stderr, buf);
+ fprintf(stderr,buf);
vfprintf(stderr, format, args);
fflush(stderr);
@@ -583,9 +583,19 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
{
+ rfbClientIteratorPtr i=rfbGetClientIterator(rfbScreen);
+ rfbClientPtr cl,cl1=rfbClientIteratorNext(i);
+ while(cl1) {
+ cl=rfbClientIteratorNext(i);
+ rfbClientConnectionGone(cl1);
+ cl1=cl;
+ }
+ rfbReleaseClientIterator(i);
+
/* TODO: hang up on all clients and free all reserved memory */
- if(rfbScreen->colourMap.data.bytes)
- free(rfbScreen->colourMap.data.bytes);
+#define FREE_IF(x) if(rfbScreen->x) free(rfbScreen->x)
+ FREE_IF(colourMap.data.bytes);
+ FREE_IF(underCursorBuffer);
TINI_MUTEX(rfbScreen->cursorMutex);
free(rfbScreen);
}
diff --git a/rfbserver.c b/rfbserver.c
index 024b851..913ee54 100644
--- a/rfbserver.c
+++ b/rfbserver.c
@@ -124,6 +124,7 @@ void
rfbReleaseClientIterator(rfbClientIteratorPtr iterator)
{
IF_PTHREADS(if(iterator->next) rfbDecrClientRef(iterator->next));
+ free(iterator);
}
@@ -372,6 +373,8 @@ rfbClientConnectionGone(cl)
pointerClient = NULL;
sraRgnDestroy(cl->modifiedRegion);
+ sraRgnDestroy(cl->requestedRegion);
+ sraRgnDestroy(cl->copyRegion);
UNLOCK(rfbClientListMutex);
@@ -1123,6 +1126,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
break;
}
}
+ sraRgnReleaseIterator(i);
if ( nUpdateRegionRects == 0xFFFF &&
!rfbSendLastRectMarker(cl) ) {