HMG_Upper() function causes a memory leak
Moderator: Rathinagiri
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
HMG_Upper() function causes a memory leak
Hi Claudio,
I do not know well if this would helps to you in HMG_UPPER case: Or if these C functions are acting under ANSI mode with UTF8 because cdp parameter.
Please check: hb_cdpnDupUpper(), hb_cdpnDupLower(), hb_cdpnDup2Upper(), hb_cdpnDup2Lower() or hb_strUpper() and hb_strLower()
ADDED LATER:
These other C functions: hb_strncpy(), hb_strncpyLower(), hb_strncpyUpper()
I do not know well if this would helps to you in HMG_UPPER case: Or if these C functions are acting under ANSI mode with UTF8 because cdp parameter.
Please check: hb_cdpnDupUpper(), hb_cdpnDupLower(), hb_cdpnDup2Upper(), hb_cdpnDup2Lower() or hb_strUpper() and hb_strLower()
ADDED LATER:
These other C functions: hb_strncpy(), hb_strncpyLower(), hb_strncpyUpper()
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: HMG_Upper() function causes a memory leak
Thanks Pablo.Pablo César wrote:Hi Claudio,
I do not know well if this would helps to you in HMG_UPPER case:
Screen11.png
Or if these C functions are acting under ANSI mode with UTF8 because cdp parameter.
Please check: hb_cdpnDupUpper(), hb_cdpnDupLower(), hb_cdpnDup2Upper(), hb_cdpnDup2Lower() or hb_strUpper() and hb_strLower()
ADDED LATER:
These other C functions: hb_strncpy(), hb_strncpyLower(), hb_strncpyUpper()
I fixed the problem in hmg_upper and hmg_lower
Re: HMG_Upper() function causes a memory leak
Hi Claudio
Memory leaks are a serious problem in HMG.
I do not know how you solved it in hmg_upper and hmg_lower.
But I noticed that this occurs in all C functions, that uses HMG_parc, HMG_retc and HMG_storc macros.
So I checked this more accurately, and it seems to me that I was able to locate the bug.
HMG_UNICODE.h wrote:Code: Select all
#define HMG_CHAR_TO_WCHAR(c) ((c != NULL) ? hb_osStrU16Encode(c) : NULL) // return WCHAR #define HMG_parc(n) HMG_CHAR_TO_WCHAR (hb_parc(n)) #define HMG_parvc(n,i) HMG_CHAR_TO_WCHAR (hb_parvc(n,i)) #define HMG_arrayGetCPtr(a,n) HMG_CHAR_TO_WCHAR (hb_arrayGetCPtr(a,n)) #define HMG_WCHAR_TO_CHAR(c) hb_osStrU16Decode(c) // return CHAR #define HMG_retc(c) hb_retc (HMG_WCHAR_TO_CHAR(c)) #define HMG_storc(c,i) hb_storc (HMG_WCHAR_TO_CHAR(c),i) #define HMG_storvc(c,l,n) hb_storvc (HMG_WCHAR_TO_CHAR(c),l,n) #define HMG_retclen(c,l) hb_retclen (HMG_WCHAR_TO_CHAR(c),l) #define HMG_retc_buffer(c) hb_retc_buffer (HMG_WCHAR_TO_CHAR(c)) #define HMG_itemPutC(p, c) hb_itemPutC (p, HMG_WCHAR_TO_CHAR(c)) #define HMG_itemPutCL(p, c, l) hb_itemPutCL (p, HMG_WCHAR_TO_CHAR(c), l) #define HMG_itemPutCConst(p, c) hb_itemPutCConst (p, HMG_WCHAR_TO_CHAR(c)) #define HMG_itemPutCLConst(p, c, l) hb_itemPutCLConst(p, HMG_WCHAR_TO_CHAR(c), l) #define HMG_itemPutCPtr(p, c) hb_itemPutCPtr (p, HMG_WCHAR_TO_CHAR(c)) #define HMG_itemPutCLPtr(p, c, l) hb_itemPutCLPtr (p, HMG_WCHAR_TO_CHAR(c), l)
Note that the buffer is initialized by using hb_xgrab function:set.c (in Harbour) wrote:Code: Select all
HB_WCHAR * hb_osStrU16Encode( const char * pszName ) { if( hb_vmIsReady() ) { PHB_CODEPAGE cdp = hb_vmCDP(); if( cdp ) { HB_SIZE nLen, nSize; HB_WCHAR * pszBufferW; nLen = strlen( pszName ); nSize = hb_cdpStrAsU16Len( cdp, pszName, nLen, 0 ); pszBufferW = ( HB_WCHAR * ) hb_xgrab( ( nSize + 1 ) * sizeof( HB_WCHAR ) ); hb_cdpStrToU16( cdp, HB_CDP_ENDIAN_NATIVE, pszName, nLen, pszBufferW, nSize + 1 ); return pszBufferW; } } return hb_mbtowc( pszName ); /* No HVM stack */ }
pszBufferW = ( HB_WCHAR * ) hb_xgrab( ( nSize + 1 ) * sizeof( HB_WCHAR ) );
and it is nowhere released by hb_xfree.
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: HMG_Upper() function causes a memory leak
Many thanks for the info. I will fixed
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
HMG_Upper() function causes a memory leak
Congratulations guys.
This is teamwork, pure altruism and a lot of fellowship.
It is not enough to just criticize.
The guy, detects, looks for a possible solution and informs.
Perfect work of the two colleagues.
I love this kind of things. Congratulations Claudio and Krzysztof.
We are all winners when there is competence on both sides and a lot of humility.
I want to learn a lot from you.
Many thanks to both.
My best regards
This is teamwork, pure altruism and a lot of fellowship.
It is not enough to just criticize.
The guy, detects, looks for a possible solution and informs.
Perfect work of the two colleagues.
I love this kind of things. Congratulations Claudio and Krzysztof.
We are all winners when there is competence on both sides and a lot of humility.
I want to learn a lot from you.
Many thanks to both.
My best regards
Last edited by Pablo César on Thu Jan 19, 2017 1:19 pm, edited 1 time in total.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: HMG_Upper() function causes a memory leak
+1Pablo César wrote: ↑Thu Jan 19, 2017 12:41 am
Congratulations guys.
This is teamwork, pure altruism and a lot of fellowship.
Many thanks to both.
My best regards
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- serge_girard
- Posts: 3167
- Joined: Sun Nov 25, 2012 2:44 pm
- DBs Used: 1 MySQL - MariaDB
2 DBF - Location: Belgium
- Contact:
Re: HMG_Upper() function causes a memory leak
Rightly said. It is the base of HMG. Congratulations to all who work hard for it.Pablo César wrote: ↑Thu Jan 19, 2017 12:41 am Congratulations guys.
This is teamwork, pure altruism and a lot of fellowship.
Regards,
Anand