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  af403073f055323ce72efcce4e990c0c52743c92 (commit)
       via  5a5216ffb900a9ca63d4436d79a8e7efe9ffca73 (commit)
       via  bcee0100820e0c5fd84df715a36575f2ca2423e4 (commit)
       via  ea19294b70b15175b5e426767db13e9bba0f5bea (commit)
       via  0004d38ef884d92a1daf34f67aadb8fb6d249fc9 (commit)
       via  8517f3dcef46a25e3c3f6dc9d7370f77551ede2f (commit)
      from  022421e8793584e910407f1a5f05c72c89ebfbd3 (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/af403073f055323ce72efcce4e990c0c52743c92

commit af403073f055323ce72efcce4e990c0c52743c92
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:12 2013 +0200

    Fixed memory leak due to non-freed property list structure
    
    The history is actually loaded from a file into a property list that
    is then converted to an array. The intermediate property list was
    not freed, which led to memory leak.
    
    It looks like it was a tentative of optimisation to avoid duplicating
    an already allocated string and re-use the pointer instead, but this
    means it is not possible to free the original container as it would
    free the string too.
    
    There is a better way to do this, but it requires an API change on the
    WUtil library so it is left for a future improvment.

diff --git a/src/dialog.c b/src/dialog.c
index 0508747..7b0b4f2 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -191,24 +191,38 @@ static WMArray *LoadHistory(const char *filename, int max)
        WMPropList *plitem;
        WMArray *history;
        int i, num;
+       char *str;
 
        history = WMCreateArrayWithDestructor(1, wfree);
        WMAddToArray(history, wstrdup(""));
 
        plhistory = WMReadPropListFromFile(filename);
 
-       if (plhistory && WMIsPLArray(plhistory)) {
-               num = WMGetPropListItemCount(plhistory);
-
-               for (i = 0; i < num; ++i) {
-                       plitem = WMGetFromPLArray(plhistory, i);
-                       if (WMIsPLString(plitem) && WMFindInArray(history, 
strmatch,
-                                                                 
WMGetFromPLString(plitem)) == WANotFound) {
-                               WMAddToArray(history, 
WMGetFromPLString(plitem));
-                               if (--max <= 0)
-                                       break;
+       if (plhistory) {
+               if (WMIsPLArray(plhistory)) {
+                       num = WMGetPropListItemCount(plhistory);
+
+                       for (i = 0; i < num; ++i) {
+                               plitem = WMGetFromPLArray(plhistory, i);
+                               if (WMIsPLString(plitem)) {
+                                       str = WMGetFromPLString(plitem);
+                                       if (WMFindInArray(history, strmatch, 
str) == WANotFound) {
+                                               /*
+                                                * The string here is 
duplicated because it will be freed
+                                                * automatically when the array 
is deleted. This is not really
+                                                * great because it is already 
an allocated string,
+                                                * unfortunately we cannot 
re-use it because it will be freed
+                                                * when we discard the PL (and 
we don't want to waste the PL's
+                                                * memory either)
+                                                */
+                                               WMAddToArray(history, 
wstrdup(str));
+                                               if (--max <= 0)
+                                                       break;
+                                       }
+                               }
                        }
                }
+               WMReleasePropList(plhistory);
        }
 
        return history;

http://repo.or.cz/w/wmaker-crm.git/commit/5a5216ffb900a9ca63d4436d79a8e7efe9ffca73

commit 5a5216ffb900a9ca63d4436d79a8e7efe9ffca73
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:11 2013 +0200

    Changed method to limit the number of History entries loaded
    
    The previous code limited the number of entries that were read into
    the history array, but the user is expecting a maximum on the
    number of entries displayed. This can make a little difference in
    two cases:
     - if there are duplicate entries (dups are checked for and removed)
     - if some entries are not strings (unlikely, but not impossible)
    
    The new code just stops adding history entries when the user
    specified count is reached.

diff --git a/src/dialog.c b/src/dialog.c
index a3e7e7e..0508747 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -199,14 +199,15 @@ static WMArray *LoadHistory(const char *filename, int max)
 
        if (plhistory && WMIsPLArray(plhistory)) {
                num = WMGetPropListItemCount(plhistory);
-               if (num > max)
-                       num = max;
 
                for (i = 0; i < num; ++i) {
                        plitem = WMGetFromPLArray(plhistory, i);
                        if (WMIsPLString(plitem) && WMFindInArray(history, 
strmatch,
-                                                                 
WMGetFromPLString(plitem)) == WANotFound)
+                                                                 
WMGetFromPLString(plitem)) == WANotFound) {
                                WMAddToArray(history, 
WMGetFromPLString(plitem));
+                               if (--max <= 0)
+                                       break;
+                       }
                }
        }
 

http://repo.or.cz/w/wmaker-crm.git/commit/bcee0100820e0c5fd84df715a36575f2ca2423e4

commit bcee0100820e0c5fd84df715a36575f2ca2423e4
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:10 2013 +0200

    Added a few 'const' to filename parameters for History functions
    
    Name of file is, as usual, a read-only parameter.

diff --git a/src/dialog.c b/src/dialog.c
index 91a3d83..a3e7e7e 100644
--- a/src/dialog.c
+++ b/src/dialog.c
@@ -167,7 +167,7 @@ typedef struct _WMInputPanelWithHistory {
        int varpos;
 } WMInputPanelWithHistory;
 
-static char *HistoryFileName(char *name)
+static char *HistoryFileName(const char *name)
 {
        char *filename = NULL;
 
@@ -185,7 +185,7 @@ static int strmatch(const void *str1, const void *str2)
        return !strcmp((const char *)str1, (const char *)str2);
 }
 
-static WMArray *LoadHistory(char *filename, int max)
+static WMArray *LoadHistory(const char *filename, int max)
 {
        WMPropList *plhistory;
        WMPropList *plitem;
@@ -195,7 +195,7 @@ static WMArray *LoadHistory(char *filename, int max)
        history = WMCreateArrayWithDestructor(1, wfree);
        WMAddToArray(history, wstrdup(""));
 
-       plhistory = WMReadPropListFromFile((char *)filename);
+       plhistory = WMReadPropListFromFile(filename);
 
        if (plhistory && WMIsPLArray(plhistory)) {
                num = WMGetPropListItemCount(plhistory);
@@ -213,7 +213,7 @@ static WMArray *LoadHistory(char *filename, int max)
        return history;
 }
 
-static void SaveHistory(WMArray * history, char *filename)
+static void SaveHistory(WMArray * history, const char *filename)
 {
        int i;
        WMPropList *plhistory;
@@ -223,7 +223,7 @@ static void SaveHistory(WMArray * history, char *filename)
        for (i = 0; i < WMGetArrayItemCount(history); ++i)
                WMAddToPLArray(plhistory, 
WMCreatePLString(WMGetFromArray(history, i)));
 
-       WMWritePropListToFile(plhistory, (char *)filename);
+       WMWritePropListToFile(plhistory, filename);
        WMReleasePropList(plhistory);
 }
 

http://repo.or.cz/w/wmaker-crm.git/commit/ea19294b70b15175b5e426767db13e9bba0f5bea

commit ea19294b70b15175b5e426767db13e9bba0f5bea
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:09 2013 +0200

    Fixed memory leak due to non-freed temporary PropList
    
    When menus are read in the PropList format, they are loaded into a
    temporary PropList object, which is parsed into the internal menu
    structure, and the PropList object is no more used. There were two
    cases where this temp object was not freed.

diff --git a/src/rootmenu.c b/src/rootmenu.c
index db81212..28bed80 100644
--- a/src/rootmenu.c
+++ b/src/rootmenu.c
@@ -574,6 +574,9 @@ static WMenu *constructPLMenu(WScreen *screen, char *path)
                return NULL;
 
        menu = configureMenu(screen, pl, False);
+
+       WMReleasePropList(pl);
+
        if (!menu)
                return NULL;
 
@@ -1075,6 +1078,9 @@ static WMenu *readPLMenuPipe(WScreen * scr, char 
**file_name)
                return NULL;
 
        menu = configureMenu(scr, plist, False);
+
+       WMReleasePropList(plist);
+
        if (!menu)
                return NULL;
 

http://repo.or.cz/w/wmaker-crm.git/commit/0004d38ef884d92a1daf34f67aadb8fb6d249fc9

commit 0004d38ef884d92a1daf34f67aadb8fb6d249fc9
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:08 2013 +0200

    WPrefs: Added const attribute to statically stored strings
    
    Now that the function handling the configuration dictionnary are
    const correct, the key stored in static array can be given the const
    attribute.

diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c
index d82bc6f..7cb85f3 100644
--- a/WPrefs.app/Expert.c
+++ b/WPrefs.app/Expert.c
@@ -34,7 +34,7 @@ static const struct {
                OPTION_USERDEF
        } class;
 
-       char *op_name; /* The identifier for the option in the config file */
+       const char *op_name;  /* The identifier for the option in the config 
file */
 
 } expert_options[] = {
 
diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c
index d5b2ce1..ef48656 100644
--- a/WPrefs.app/KeyboardShortcuts.c
+++ b/WPrefs.app/KeyboardShortcuts.c
@@ -66,11 +66,11 @@ typedef struct _Panel {
  * Second is the text displayed to the user
  */
 static const struct {
+       const char *key;
        /*
-        * Fixme: these strings should be 'const', but 'GetStringForKey'
-        *        and 'WMAddListItem' do not allow us to do so
+        * Fixme: this string should be 'const', but 'WMAddListItem'
+        *        do not allow us to do so
         */
-       char *key;
        char *title;
 } keyOptions[] = {
        { "RootMenuKey",    N_("Open applications menu") },

http://repo.or.cz/w/wmaker-crm.git/commit/8517f3dcef46a25e3c3f6dc9d7370f77551ede2f

commit 8517f3dcef46a25e3c3f6dc9d7370f77551ede2f
Author: Christophe CURIS <[email protected]>
Date:   Wed May 8 15:44:07 2013 +0200

    WPrefs: Added the proper 'const' attribute to the dictionnary functions
    
    A common argument to all these functions is the name of the key to
    operate on, and this name is never modified by the functions. Marking
    it as const reflects this, and can allow compiler to generate better
    results thanks to this info.

diff --git a/WPrefs.app/WPrefs.c b/WPrefs.app/WPrefs.c
index 94b248f..413bee9 100644
--- a/WPrefs.app/WPrefs.c
+++ b/WPrefs.app/WPrefs.c
@@ -815,7 +815,7 @@ static void loadConfigurations(WMScreen * scr, WMWindow * 
mainw)
        WindowMakerDB = db;
 }
 
-WMPropList *GetObjectForKey(char *defaultName)
+WMPropList *GetObjectForKey(const char *defaultName)
 {
        WMPropList *object = NULL;
        WMPropList *key = WMCreatePLString(defaultName);
@@ -829,7 +829,7 @@ WMPropList *GetObjectForKey(char *defaultName)
        return object;
 }
 
-void SetObjectForKey(WMPropList * object, char *defaultName)
+void SetObjectForKey(WMPropList * object, const char *defaultName)
 {
        WMPropList *key = WMCreatePLString(defaultName);
 
@@ -837,7 +837,7 @@ void SetObjectForKey(WMPropList * object, char *defaultName)
        WMReleasePropList(key);
 }
 
-void RemoveObjectForKey(char *defaultName)
+void RemoveObjectForKey(const char *defaultName)
 {
        WMPropList *key = WMCreatePLString(defaultName);
 
@@ -846,7 +846,7 @@ void RemoveObjectForKey(char *defaultName)
        WMReleasePropList(key);
 }
 
-char *GetStringForKey(char *defaultName)
+char *GetStringForKey(const char *defaultName)
 {
        WMPropList *val;
 
@@ -861,7 +861,7 @@ char *GetStringForKey(char *defaultName)
        return WMGetFromPLString(val);
 }
 
-WMPropList *GetArrayForKey(char *defaultName)
+WMPropList *GetArrayForKey(const char *defaultName)
 {
        WMPropList *val;
 
@@ -876,7 +876,7 @@ WMPropList *GetArrayForKey(char *defaultName)
        return val;
 }
 
-WMPropList *GetDictionaryForKey(char *defaultName)
+WMPropList *GetDictionaryForKey(const char *defaultName)
 {
        WMPropList *val;
 
@@ -891,7 +891,7 @@ WMPropList *GetDictionaryForKey(char *defaultName)
        return val;
 }
 
-int GetIntegerForKey(char *defaultName)
+int GetIntegerForKey(const char *defaultName)
 {
        WMPropList *val;
        char *str;
@@ -915,7 +915,7 @@ int GetIntegerForKey(char *defaultName)
        return value;
 }
 
-Bool GetBoolForKey(char *defaultName)
+Bool GetBoolForKey(const char *defaultName)
 {
        int value;
        char *str;
@@ -937,7 +937,7 @@ Bool GetBoolForKey(char *defaultName)
        return False;
 }
 
-void SetIntegerForKey(int value, char *defaultName)
+void SetIntegerForKey(int value, const char *defaultName)
 {
        WMPropList *object;
        char buffer[128];
@@ -949,7 +949,7 @@ void SetIntegerForKey(int value, char *defaultName)
        WMReleasePropList(object);
 }
 
-void SetStringForKey(char *value, char *defaultName)
+void SetStringForKey(char *value, const char *defaultName)
 {
        WMPropList *object;
 
@@ -959,7 +959,7 @@ void SetStringForKey(char *value, char *defaultName)
        WMReleasePropList(object);
 }
 
-void SetBoolForKey(Bool value, char *defaultName)
+void SetBoolForKey(Bool value, const char *defaultName)
 {
        static WMPropList *yes = NULL, *no = NULL;
 
@@ -971,7 +971,7 @@ void SetBoolForKey(Bool value, char *defaultName)
        SetObjectForKey(value ? yes : no, defaultName);
 }
 
-void SetSpeedForKey(int speed, char *defaultName)
+void SetSpeedForKey(int speed, const char *defaultName)
 {
        char *str;
 
@@ -999,7 +999,7 @@ void SetSpeedForKey(int speed, char *defaultName)
                SetStringForKey(str, defaultName);
 }
 
-int GetSpeedForKey(char *defaultName)
+int GetSpeedForKey(const char *defaultName)
 {
        char *str;
        int i;
diff --git a/WPrefs.app/WPrefs.h b/WPrefs.app/WPrefs.h
index 5100ef6..6cc02b7 100644
--- a/WPrefs.app/WPrefs.h
+++ b/WPrefs.app/WPrefs.h
@@ -87,27 +87,27 @@ WMWindow *GetWindow(Panel *panel);
 
 /* manipulate the dictionary for the WindowMaker domain */
 
-WMPropList *GetObjectForKey(char *defaultName);
+WMPropList *GetObjectForKey(const char *defaultName);
 
-void SetObjectForKey(WMPropList *object, char *defaultName);
+void SetObjectForKey(WMPropList *object, const char *defaultName);
 
-void RemoveObjectForKey(char *defaultName);
+void RemoveObjectForKey(const char *defaultName);
 
-char *GetStringForKey(char *defaultName);
+char *GetStringForKey(const char *defaultName);
 
-int GetIntegerForKey(char *defaultName);
+int GetIntegerForKey(const char *defaultName);
 
-Bool GetBoolForKey(char *defaultName);
+Bool GetBoolForKey(const char *defaultName);
 
-int GetSpeedForKey(char *defaultName);
+int GetSpeedForKey(const char *defaultName);
 
-void SetIntegerForKey(int value, char *defaultName);
+void SetIntegerForKey(int value, const char *defaultName);
 
-void SetStringForKey(char *value, char *defaultName);
+void SetStringForKey(char *value, const char *defaultName);
 
-void SetBoolForKey(Bool value, char *defaultName);
+void SetBoolForKey(Bool value, const char *defaultName);
 
-void SetSpeedForKey(int speed, char *defaultName);
+void SetSpeedForKey(int speed, const char *defaultName);
 
 
 

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

Summary of changes:
 WPrefs.app/Expert.c            |    2 +-
 WPrefs.app/KeyboardShortcuts.c |    6 ++--
 WPrefs.app/WPrefs.c            |   26 +++++++++++-----------
 WPrefs.app/WPrefs.h            |   22 +++++++++---------
 src/dialog.c                   |   47 ++++++++++++++++++++++++++-------------
 src/rootmenu.c                 |    6 +++++
 6 files changed, 65 insertions(+), 44 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