public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
[parent not found: <1342195424.30517.ezmlm@cygwin.com>]
[parent not found: <1342107001.13284.ezmlm@cygwin.com>]
[parent not found: <1342037244.32732.ezmlm@cygwin.com>]
[parent not found: <1341614850.23157.ezmlm@cygwin.com>]
[parent not found: <1341437446.12368.ezmlm@cygwin.com>]
* Differences between C++ 'new' operator and 'malloc()' (NOT a C/C++ question)
@ 2012-07-04  9:45 Claude SIMON
  2012-07-04 13:48 ` Ryan Johnson
  0 siblings, 1 reply; 19+ messages in thread
From: Claude SIMON @ 2012-07-04  9:45 UTC (permalink / raw)
  To: cygwin

Hello everybody !

I have some C++ code that I want to use in a native Java component
compiled with Cygwin g++.

I also use exactly the same C++ code in a command-line tool ('.exe' binary).

When I compile the tool with Visual C++, it works. When I compile the tool
with g++, it works.

When I compile the component with Visual C++, it works. When I compile the
component with g++... it crashes.

With 'gdb', I found that the problem happens when calling the 'malloc'
function (as soon as the function is called, NOT when the returned
allocated memory is used). When I replace the 'malloc' by a the C++ 'new'
operator, the component compiled with Cygwin g++ doesn't crash anymore.

To summarize, having some code written in C++ :
	- used in a command line tool :
		- using 'malloc' :
			- compiled with Visual C++ : works.
			- compiled with Cygwin g++ : works.
	- used in a Java native component :
		- using 'malloc' :
			- compiled with Visual C++ : works.
			- compiled with Cygwin g++ : CRASHES.
		- using the C++ 'new' operator :
			- compiled with Visual C++ : works.
			- compiled with Cygwin g++ : works.

I thought that the C++ 'new' operator calls the 'malloc' function, but
this seems not to be the case. As I want to use 'malloc'-like functions
rather than the C++ 'new' operator, I wonder which functions are used in
the C++ 'new' operator to allocate memory (and naturally which functions
are used in the C++ 'delete' operator to free the memory).

If it can be of some use, the component/tool can be found at
http://zeusw.org/intl/expp . The g++ version is 4.5.3.

Thanks !

--
Claude SIMON (sc.CYGWIN;COM@zeusw.org)
(Sorry for my poor English ; I'm French)



--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2012-07-18 10:23 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <1341539419.17571.ezmlm@cygwin.com>
2012-07-10 16:46 ` Differences between C++ 'new' operator and 'malloc()' (NOT a C/C++ question) Claude SIMON
2012-07-11 19:47   ` Ryan Johnson
     [not found] <1342195424.30517.ezmlm@cygwin.com>
2012-07-18  8:03 ` Claude SIMON
2012-07-18  8:21 ` Claude SIMON
2012-07-18  8:42 ` Claude SIMON
2012-07-18  9:27   ` Eliot Moss
2012-07-18 10:23     ` Yaakov (Cygwin/X)
     [not found] <1342107001.13284.ezmlm@cygwin.com>
2012-07-12 16:00 ` Claude SIMON
2012-07-13  8:12   ` Csaba Raduly
2012-07-13  8:26   ` Al Slater
2012-07-13 13:03     ` Ryan Johnson
     [not found] <1342037244.32732.ezmlm@cygwin.com>
2012-07-12 12:12 ` Claude SIMON
2012-07-12 14:17   ` Ryan Johnson
     [not found] <1341614850.23157.ezmlm@cygwin.com>
2012-07-10 16:51 ` Claude SIMON
     [not found] <1341437446.12368.ezmlm@cygwin.com>
2012-07-05 13:37 ` Claude SIMON
2012-07-05 20:05   ` Ryan Johnson
2012-07-06 11:48   ` NightStrike
2012-07-04  9:45 Claude SIMON
2012-07-04 13:48 ` Ryan Johnson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).