Mercurial > dwindows
diff win/dw.c @ 1884:71780cf68aa2
More container and tree changes on all platforms regarding memory.
This should fix GTK3 memory leaks I wasn't previously aware of...
but it will cause all platforms to leak memory if strings returned
from dw_container_query_start(), dw_container_query_next() and
dw_tree_get_title() are not freed with dw_free() when using version 3.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 28 Aug 2013 23:47:40 +0000 |
parents | 39ef93f82f04 |
children | f7d408a47752 |
line wrap: on
line diff
--- a/win/dw.c Thu Aug 15 18:51:56 2013 +0000 +++ b/win/dw.c Wed Aug 28 23:47:40 2013 +0000 @@ -9644,9 +9644,10 @@ int _index = ListView_GetNextItem(handle, -1, flags); void **params; int type = _DW_DATA_TYPE_STRING; + char *retval = NULL; if(_index == -1) - return NULL; + return retval; if(flags & DW_CR_RETDATA) type = _DW_DATA_TYPE_POINTER; @@ -9658,9 +9659,17 @@ ListView_GetItem(handle, &lvi); params = (void **)lvi.lParam; + + if(params) + { + if(type == _DW_DATA_TYPE_STRING && params[type]) + retval = _strdup((char *)params[type]); + else + retval = (char *)params[type]; + } dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); - return params ? (char *)params[type] : NULL; + return retval; } /* @@ -9677,11 +9686,12 @@ int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index")); void **params; int type = _DW_DATA_TYPE_STRING; + char *retval = NULL; _index = ListView_GetNextItem(handle, _index, flags); if(_index == -1) - return NULL; + return retval; if(flags & DW_CR_RETDATA) type = _DW_DATA_TYPE_POINTER; @@ -9694,8 +9704,16 @@ ListView_GetItem(handle, &lvi); params = (void **)lvi.lParam; + if(params) + { + if(type == _DW_DATA_TYPE_STRING && params[type]) + retval = _strdup((char *)params[type]); + else + retval = (char *)params[type]; + } + dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); - return params ? (char *)params[type] : NULL; + return retval; } /*