This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project wmaker-crm.git.

The branch, next has been updated
       via  4f99aa9d6b470667d2b8791c065d946b279c8120 (commit)
      from  25ae1fe05308dd9326e00977d447ebc0a9ce290c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://repo.or.cz/w/wmaker-crm.git/commit/4f99aa9d6b470667d2b8791c065d946b279c8120

commit 4f99aa9d6b470667d2b8791c065d946b279c8120
Author: David Maciejak <[email protected]>
Date:   Mon Mar 31 23:34:34 2014 +0800

    wrlib: Added clean functions to wrlib
    
    Some memory is never freed when leaving the lib.

diff --git a/wrlib/context.c b/wrlib/context.c
index b6794d08..04228ed4 100644
--- a/wrlib/context.c
+++ b/wrlib/context.c
@@ -688,6 +688,17 @@ RContext *RCreateContext(Display * dpy, int screen_number, 
const RContextAttribu
        return context;
 }
 
+void RDestroyContext(RContext * context)
+{
+       if (context) {
+               if (context && context->attribs)
+                       free(context->attribs);
+               if (context && context->copy_gc)
+                       XFreeGC(context->dpy, context->copy_gc);
+               free(context);
+       }
+}
+
 static Bool bestContext(Display * dpy, int screen_number, RContext * context)
 {
        XVisualInfo *vinfo = NULL, rvinfo;
diff --git a/wrlib/convert.c b/wrlib/convert.c
index f3c9a49d..867a3d8a 100644
--- a/wrlib/convert.c
+++ b/wrlib/convert.c
@@ -62,6 +62,32 @@ typedef struct RStdConversionTable {
 static RConversionTable *conversionTable = NULL;
 static RStdConversionTable *stdConversionTable = NULL;
 
+static void release_conversion_table()
+{
+       RConversionTable *tmp = conversionTable;
+       while (tmp) {
+               RConversionTable *tmp_to_delete = tmp;
+               tmp = tmp->next;
+               free(tmp_to_delete);
+       }
+}
+
+static void release_std_conversion_table()
+{
+       RStdConversionTable *tmp = stdConversionTable;
+       while (tmp) {
+               RStdConversionTable *tmp_to_delete = tmp;
+               tmp = tmp->next;
+               free(tmp_to_delete);
+       }
+}
+
+void RDestroyConvertTables()
+{
+       release_conversion_table();
+       release_std_conversion_table();
+}
+
 static unsigned short *computeTable(unsigned short mask)
 {
        RConversionTable *tmp = conversionTable;
@@ -356,7 +382,6 @@ static RXImage *image2TrueColor(RContext * ctx, RImage * 
image)
                }
 
        }
-
        return ximg;
 }
 
diff --git a/wrlib/libwraster.map b/wrlib/libwraster.map
index 6e165ef0..422af756 100644
--- a/wrlib/libwraster.map
+++ b/wrlib/libwraster.map
@@ -33,6 +33,7 @@ LIBWRASTER3
     RConvertImageMask;
     RCopyArea;
     RCreateContext;
+    RDestroyContext;
     RCreateImage;
     RCreateImageFromDrawable;
     RCreateImageFromXImage;
diff --git a/wrlib/load.c b/wrlib/load.c
index 8e0d34dc..5e0e8cb4 100644
--- a/wrlib/load.c
+++ b/wrlib/load.c
@@ -105,11 +105,28 @@ char **RSupportedFileFormats(void)
        return tmp;
 }
 
+static void destroy_cache(void)
+{
+       if (RImageCacheSize > 0) {
+               for (int i = 0; i < RImageCacheSize; i++) {
+                       if (RImageCache[i].file) {
+                               free(RImageCache[i].file);
+                               RImageCache[i].file = NULL;
+                               RReleaseImage(RImageCache[i].image);
+                       }
+
+               }
+               free(RImageCache);
+       }
+}
+
 /* cleaning third-party libs at shutdown */
 void RShutdown() {
 #ifdef USE_MAGICK
        MagickWandTerminus();
 #endif
+       destroy_cache();
+       RDestroyConvertTables();
 }
 
 static void init_cache(void)
diff --git a/wrlib/wraster.h b/wrlib/wraster.h
index c4ed2310..a87eb1c5 100644
--- a/wrlib/wraster.h
+++ b/wrlib/wraster.h
@@ -461,11 +461,18 @@ void RPutXImage(RContext *context, Drawable d, GC gc, 
RXImage *ximage,
                 int src_x, int src_y, int dest_x, int dest_y,
                 unsigned width, unsigned height);
 
+void RDestroyConvertTables();
+
 /* do not free the returned string! */
 const char *RMessageForError(int errorCode);
 
 int RBlurImage(RImage *image);
 
+
+#ifdef USE_MAGICK
+       extern void MagickWandTerminus();
+#endif
+
 /****** Global Variables *******/
 
 extern int RErrorCode;

-----------------------------------------------------------------------

Summary of changes:
 wrlib/context.c      |   11 +++++++++++
 wrlib/convert.c      |   27 ++++++++++++++++++++++++++-
 wrlib/libwraster.map |    1 +
 wrlib/load.c         |   17 +++++++++++++++++
 wrlib/wraster.h      |    7 +++++++
 5 files changed, 62 insertions(+), 1 deletions(-)


repo.or.cz automatic notification. Contact project admin [email protected]
if you want to unsubscribe, or site admin [email protected] if you receive
no reply.
-- 
wmaker-crm.git ("The Window Maker window manager")


-- 
To unsubscribe, send mail to [email protected].

Reply via email to