List:MySQL on Win32« Previous MessageNext Message »
From:Michael Widenius Date:September 3 1999 12:37am
Subject:Memory trashing with mySQL and Win32?
View as plain text  
>>>>> "Ray" == Ray Akey <rakey@stripped> writes:

Ray> Greetings,
Ray> I am having problems with mySQL and developing a win32 client application
Ray> under Microsoft Visual C++ 5.

Ray> Here is what is happening:

Ray> I allocate a MYSQL handle of size sizeof(MYSQL).
Ray> I then perform a mysql_real_connect() with the appropriate arguments.
Ray> The problem is that the current object pointer (this) is being trashed and
Ray> its window handle is trashed also..

Ray> Here is the code that causes the problem.  It is a snippet from a dialog
Ray> box:

Ray> In the code below, cData has bee previously allocated using malloc().
Ray> If I remove (comment out) the mysql_real_connect() call, things work fine.

Ray> // cData is allocated and initalized as follows:
Ray> cData = malloc(sizeof(MYSQL));
Ray> memset(cData, 0, sizeof(MYSQL));

Ray> // up to here,, the "this" pointer and the window handle are ok..
Ray>  if(mysql_real_connect( cData, "192.168.0.3", "ray", "mypassword",
Ray> MYSQL_PORT, NULL, 0))
Ray>  {
Ray>   // here is where the problem occurs..
Ray>   // as the "this" pointer is altered and the current window handle becomes
Ray> corrupted.
Ray>   CDialog::OnOK(); // If connect successful, call CDialog::OnOK()
Ray>  }
Ray>  else
Ray>  {
Ray>   // otherwise call CDialog::OnCancel()
Ray>   CDialog::OnCancel();
Ray>  }

Ray> Has anyone ese had problems of this sort with mySQL under win32?  Is there a
Ray> problem with libmysql.lib?

Hi!

I have now tested your problem with both the shareware version and the 
registered version (You can find the libs from the registered MySQL
version at http://www.mysql.com/download_win.html).

Both version worked without any problems for me!

I noticed that you did never even try the newer libs from the
registered version (as you had the wrong number of arguments to
mysql_real_connect()), even if I earlier suggested that you should
have used these.

At any rate, I recommend you to use the newer libs as these has new
features that can be used against newer MySQL servers but they will
also work with an old server without any problems!

The problem you where facing was probably that you had included the
wrong types of standard libraries with your application!

You should use the 'multithreaded' or 'multhreaded-debug' version of
the libraries!

The following zip file includes a corrected version of your program
that works both with the shareware libs and the newer libs.  I have
also included makefiles for both version so that you can check what I
did (and hopefully repeat it)

Regards,
Monty

PS: If you had included a project file with your test, I would have
    been able to test this MUCH faster!


Thread
Memory trashing with mySQL and Win32?Ray Akey30 Aug
  • PHP or Cold Fusion?Stefan Vesterlund30 Aug
    • Re: PHP or Cold Fusion?Michael Stearne31 Aug
    • Re: PHP or Cold Fusion?Simson L. Garfinkel31 Aug
      • Re: PHP or Cold Fusion?(Hood Gardner)31 Aug
    • Re: PHP or Cold Fusion?Michael Stearne31 Aug
      • RE: PHP or Cold Fusion?Rob Raisch31 Aug
  • Re: Memory trashing with mySQL and Win32?Thomas Bouton30 Aug
  • Re: Memory trashing with mySQL and Win32?Ray Akey31 Aug
    • Re: Memory trashing with mySQL and Win32?Michael Widenius31 Aug
  • Re: Memory trashing with mySQL and Win32?targeted31 Aug
  • Re: Memory trashing with mySQL and Win32?Ray Akey1 Sep
  • Re: Memory trashing with mySQL and Win32?Ray Akey1 Sep
  • Memory trashing with mySQL and Win32?Michael Widenius3 Sep
RE: PHP or Cold Fusion?J Garcia31 Aug