Commit efa12fa9 authored by dscho's avatar dscho

memleaks patched

parent 160c85f4
memory leaks squashed (localtime pseudo leak is still there :-)
small improvements for OSXvnc (still not working correctly)
synced with TightVNC 1.2.3 synced with TightVNC 1.2.3
solaris compile cleanups solaris compile cleanups
many x11vnc improvements many x11vnc improvements
......
...@@ -272,6 +272,8 @@ char* rfbMakeMaskForXCursor(int width,int height,char* source) ...@@ -272,6 +272,8 @@ char* rfbMakeMaskForXCursor(int width,int height,char* source)
void rfbFreeCursor(rfbCursorPtr cursor) void rfbFreeCursor(rfbCursorPtr cursor)
{ {
if(cursor) { if(cursor) {
if(cursor->richSource)
free(cursor->richSource);
free(cursor->source); free(cursor->source);
free(cursor->mask); free(cursor->mask);
free(cursor); free(cursor);
......
...@@ -262,6 +262,17 @@ int main(int argc,char** argv) ...@@ -262,6 +262,17 @@ int main(int argc,char** argv)
/* initialize the server */ /* initialize the server */
rfbInitServer(rfbScreen); 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 #ifndef BACKGROUND_LOOP_TEST
/* this is the blocking event loop, i.e. it never returns */ /* this is the blocking event loop, i.e. it never returns */
/* 40000 are the microseconds, i.e. 0.04 seconds */ /* 40000 are the microseconds, i.e. 0.04 seconds */
...@@ -274,6 +285,11 @@ int main(int argc,char** argv) ...@@ -274,6 +285,11 @@ int main(int argc,char** argv)
rfbRunEventLoop(rfbScreen,-1,TRUE); rfbRunEventLoop(rfbScreen,-1,TRUE);
/* now we could do some cool things like rendering */ /* now we could do some cool things like rendering */
while(1) sleep(5); /* render(); */ while(1) sleep(5); /* render(); */
#endif
rfbFreeCursor(rfbScreen->cursor);
free(rfbScreen->frameBuffer);
rfbScreenCleanup(rfbScreen);
return(0); return(0);
} }
...@@ -55,7 +55,7 @@ rfbLog(const char *format, ...) ...@@ -55,7 +55,7 @@ rfbLog(const char *format, ...)
time(&log_clock); time(&log_clock);
strftime(buf, 255, "%d/%m/%Y %T ", localtime(&log_clock)); strftime(buf, 255, "%d/%m/%Y %T ", localtime(&log_clock));
fprintf(stderr, buf); fprintf(stderr,buf);
vfprintf(stderr, format, args); vfprintf(stderr, format, args);
fflush(stderr); fflush(stderr);
...@@ -583,9 +583,19 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv, ...@@ -583,9 +583,19 @@ rfbScreenInfoPtr rfbGetScreen(int* argc,char** argv,
void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen) 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 */ /* TODO: hang up on all clients and free all reserved memory */
if(rfbScreen->colourMap.data.bytes) #define FREE_IF(x) if(rfbScreen->x) free(rfbScreen->x)
free(rfbScreen->colourMap.data.bytes); FREE_IF(colourMap.data.bytes);
FREE_IF(underCursorBuffer);
TINI_MUTEX(rfbScreen->cursorMutex); TINI_MUTEX(rfbScreen->cursorMutex);
free(rfbScreen); free(rfbScreen);
} }
......
...@@ -124,6 +124,7 @@ void ...@@ -124,6 +124,7 @@ void
rfbReleaseClientIterator(rfbClientIteratorPtr iterator) rfbReleaseClientIterator(rfbClientIteratorPtr iterator)
{ {
IF_PTHREADS(if(iterator->next) rfbDecrClientRef(iterator->next)); IF_PTHREADS(if(iterator->next) rfbDecrClientRef(iterator->next));
free(iterator);
} }
...@@ -372,6 +373,8 @@ rfbClientConnectionGone(cl) ...@@ -372,6 +373,8 @@ rfbClientConnectionGone(cl)
pointerClient = NULL; pointerClient = NULL;
sraRgnDestroy(cl->modifiedRegion); sraRgnDestroy(cl->modifiedRegion);
sraRgnDestroy(cl->requestedRegion);
sraRgnDestroy(cl->copyRegion);
UNLOCK(rfbClientListMutex); UNLOCK(rfbClientListMutex);
...@@ -1123,6 +1126,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion) ...@@ -1123,6 +1126,7 @@ rfbSendFramebufferUpdate(cl, givenUpdateRegion)
break; break;
} }
} }
sraRgnReleaseIterator(i);
if ( nUpdateRegionRects == 0xFFFF && if ( nUpdateRegionRects == 0xFFFF &&
!rfbSendLastRectMarker(cl) ) { !rfbSendLastRectMarker(cl) ) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment