Re: How to properly fix memory leak

2025-04-26 Thread Igor Korot
David et al, On Fri, Apr 25, 2025 at 10:48 PM David G. Johnston wrote: > > On Friday, April 25, 2025, Igor Korot wrote: >> >> >> for( int i = 0; i < PQntuples( res ); i++ ) >> { >> auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue( >> res, i, 1 ) ); >>

Re: How to properly fix memory leak

2025-04-26 Thread Laurenz Albe
On Fri, 2025-04-25 at 22:24 -0500, Igor Korot wrote: > Hi, ALL, > > [code] > auto res = PQexec( m_db, m_pimpl->m_myconv.to_bytes( query.c_str() > ).c_str() ); /* ask for binary results */ > if( PQresultStatus( res ) != PGRES_TUPLES_OK ) > { > auto err = m_pimpl->m_myconv.f

Re: How to properly fix memory leak

2025-04-26 Thread Igor Korot
Hi, Tom, On Sat, Apr 26, 2025 at 4:34 PM Tom Lane wrote: > Igor Korot writes: > auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue( > res, i, 1 ) ); > m_tablespaces.push_back( temp1 ); > > I would imagine that from_bytes()

Re: How to properly fix memory leak

2025-04-26 Thread Tom Lane
Igor Korot writes: auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue( res, i, 1 ) ); m_tablespaces.push_back( temp1 ); I would imagine that from_bytes() is producing a malloc'd string. Which part of this is responsible for

Re: How to properly fix memory leak

2025-04-26 Thread Igor Korot
Hi, Lauren’s, On Sat, Apr 26, 2025 at 3:30 PM Laurenz Albe wrote: > On Fri, 2025-04-25 at 22:24 -0500, Igor Korot wrote: > > Hi, ALL, > > > > [code] > > auto res = PQexec( m_db, m_pimpl->m_myconv.to_bytes( query.c_str() > > ).c_str() ); /* ask for binary results */ > > if( PQresultS

Re: How to properly fix memory leak

2025-04-25 Thread Igor Korot
Hi, David, On Fri, Apr 25, 2025 at 11:55 PM David G. Johnston wrote: > > On Friday, April 25, 2025, Igor Korot wrote: >> >> >> And the error case was handled correctly, right? > > > Seems like answering that requires knowing what the query is or can be. I > also have no idea what idiomatic cod

How to properly fix memory leak

2025-04-25 Thread David G. Johnston
On Friday, April 25, 2025, Igor Korot wrote: > > And the error case was handled correctly, right? > Seems like answering that requires knowing what the query is or can be. I also have no idea what idiomatic code looks like. Though, I’d probably use PQresultErrorMessage and check affirmatively

Re: How to properly fix memory leak

2025-04-25 Thread Igor Korot
Hi, David, On Fri, Apr 25, 2025 at 10:48 PM David G. Johnston wrote: > > On Friday, April 25, 2025, Igor Korot wrote: >> >> >> for( int i = 0; i < PQntuples( res ); i++ ) >> { >> auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue( >> res, i, 1 ) ); >> m

Re: How to properly fix memory leak

2025-04-25 Thread David G. Johnston
On Friday, April 25, 2025, Igor Korot wrote: > > for( int i = 0; i < PQntuples( res ); i++ ) > { > auto temp1 = m_pimpl->m_myconv.from_bytes( PQgetvalue( > res, i, 1 ) ); > m_tablespaces.push_back( temp1 ); > } // this line gives a leak according to

How to properly fix memory leak

2025-04-25 Thread Igor Korot
Hi, ALL, [code] auto res = PQexec( m_db, m_pimpl->m_myconv.to_bytes( query.c_str() ).c_str() ); /* ask for binary results */ if( PQresultStatus( res ) != PGRES_TUPLES_OK ) { auto err = m_pimpl->m_myconv.from_bytes( PQerrorMessage( m_db ) ); errorMsg.push_back( L"Up