diff options
Diffstat (limited to 'libvncserver/zrle.c')
-rw-r--r-- | libvncserver/zrle.c | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/libvncserver/zrle.c b/libvncserver/zrle.c index 2475fc0..e1f1447 100644 --- a/libvncserver/zrle.c +++ b/libvncserver/zrle.c @@ -97,21 +97,25 @@ */ /* TODO: put into rfbClient struct */ -static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4]; - +static char zrleBeforeBuf[rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4]; /* * rfbSendRectEncodingZRLE - send a given rectangle using ZRLE encoding. */ - rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) { zrleOutStream* zos; rfbFramebufferUpdateRectHeader rect; rfbZRLEHeader hdr; int i; + char *zrleBeforeBuf; + + if (cl->zrleBeforeBuf == NULL) { + cl->zrleBeforeBuf = (char *) malloc(rfbZRLETileWidth * rfbZRLETileHeight * 4 + 4); + } + zrleBeforeBuf = cl->zrleBeforeBuf; if (cl->preferredEncoding == rfbEncodingZYWRLE) { if (cl->tightQualityLevel < 0) { @@ -238,8 +242,19 @@ rfbBool rfbSendRectEncodingZRLE(rfbClientPtr cl, int x, int y, int w, int h) void rfbFreeZrleData(rfbClientPtr cl) { - if (cl->zrleData) - zrleOutStreamFree(cl->zrleData); - cl->zrleData = NULL; + if (cl->zrleData) { + zrleOutStreamFree(cl->zrleData); + } + cl->zrleData = NULL; + + if (cl->zrleBeforeBuf) { + free(cl->zrleBeforeBuf); + } + cl->zrleBeforeBuf = NULL; + + if (cl->paletteHelper) { + free(cl->paletteHelper); + } + cl->paletteHelper = NULL; } |