Mercurial > dwindows
comparison 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 |
comparison
equal
deleted
inserted
replaced
1883:0fecaedb83fa | 1884:71780cf68aa2 |
---|---|
9642 { | 9642 { |
9643 LV_ITEM lvi; | 9643 LV_ITEM lvi; |
9644 int _index = ListView_GetNextItem(handle, -1, flags); | 9644 int _index = ListView_GetNextItem(handle, -1, flags); |
9645 void **params; | 9645 void **params; |
9646 int type = _DW_DATA_TYPE_STRING; | 9646 int type = _DW_DATA_TYPE_STRING; |
9647 char *retval = NULL; | |
9647 | 9648 |
9648 if(_index == -1) | 9649 if(_index == -1) |
9649 return NULL; | 9650 return retval; |
9650 | 9651 |
9651 if(flags & DW_CR_RETDATA) | 9652 if(flags & DW_CR_RETDATA) |
9652 type = _DW_DATA_TYPE_POINTER; | 9653 type = _DW_DATA_TYPE_POINTER; |
9653 | 9654 |
9654 memset(&lvi, 0, sizeof(LV_ITEM)); | 9655 memset(&lvi, 0, sizeof(LV_ITEM)); |
9656 lvi.iItem = _index; | 9657 lvi.iItem = _index; |
9657 lvi.mask = LVIF_PARAM; | 9658 lvi.mask = LVIF_PARAM; |
9658 | 9659 |
9659 ListView_GetItem(handle, &lvi); | 9660 ListView_GetItem(handle, &lvi); |
9660 params = (void **)lvi.lParam; | 9661 params = (void **)lvi.lParam; |
9662 | |
9663 if(params) | |
9664 { | |
9665 if(type == _DW_DATA_TYPE_STRING && params[type]) | |
9666 retval = _strdup((char *)params[type]); | |
9667 else | |
9668 retval = (char *)params[type]; | |
9669 } | |
9661 | 9670 |
9662 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); | 9671 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); |
9663 return params ? (char *)params[type] : NULL; | 9672 return retval; |
9664 } | 9673 } |
9665 | 9674 |
9666 /* | 9675 /* |
9667 * Continues an existing query of a container. | 9676 * Continues an existing query of a container. |
9668 * Parameters: | 9677 * Parameters: |
9675 { | 9684 { |
9676 LV_ITEM lvi; | 9685 LV_ITEM lvi; |
9677 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index")); | 9686 int _index = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_index")); |
9678 void **params; | 9687 void **params; |
9679 int type = _DW_DATA_TYPE_STRING; | 9688 int type = _DW_DATA_TYPE_STRING; |
9689 char *retval = NULL; | |
9680 | 9690 |
9681 _index = ListView_GetNextItem(handle, _index, flags); | 9691 _index = ListView_GetNextItem(handle, _index, flags); |
9682 | 9692 |
9683 if(_index == -1) | 9693 if(_index == -1) |
9684 return NULL; | 9694 return retval; |
9685 | 9695 |
9686 if(flags & DW_CR_RETDATA) | 9696 if(flags & DW_CR_RETDATA) |
9687 type = _DW_DATA_TYPE_POINTER; | 9697 type = _DW_DATA_TYPE_POINTER; |
9688 | 9698 |
9689 memset(&lvi, 0, sizeof(LV_ITEM)); | 9699 memset(&lvi, 0, sizeof(LV_ITEM)); |
9692 lvi.mask = LVIF_PARAM; | 9702 lvi.mask = LVIF_PARAM; |
9693 | 9703 |
9694 ListView_GetItem(handle, &lvi); | 9704 ListView_GetItem(handle, &lvi); |
9695 params = (void **)lvi.lParam; | 9705 params = (void **)lvi.lParam; |
9696 | 9706 |
9707 if(params) | |
9708 { | |
9709 if(type == _DW_DATA_TYPE_STRING && params[type]) | |
9710 retval = _strdup((char *)params[type]); | |
9711 else | |
9712 retval = (char *)params[type]; | |
9713 } | |
9714 | |
9697 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); | 9715 dw_window_set_data(handle, "_dw_index", DW_INT_TO_POINTER(_index)); |
9698 return params ? (char *)params[type] : NULL; | 9716 return retval; |
9699 } | 9717 } |
9700 | 9718 |
9701 /* | 9719 /* |
9702 * Cursors the item with the text speficied, and scrolls to that item. | 9720 * Cursors the item with the text speficied, and scrolls to that item. |
9703 * Parameters: | 9721 * Parameters: |