Click here to Skip to main content
15,920,633 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 0:49
Hadi Rezaee9-Jun-01 0:49 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 0:59
Igor Sukhov9-Jun-01 0:59 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 1:08
Hadi Rezaee9-Jun-01 1:08 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 1:14
Igor Sukhov9-Jun-01 1:14 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 1:21
Hadi Rezaee9-Jun-01 1:21 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 2:11
Igor Sukhov9-Jun-01 2:11 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 4:34
Hadi Rezaee9-Jun-01 4:34 
GeneralRe: Convert ... Pin
Christian Skovdal Andersen10-Jun-01 1:55
Christian Skovdal Andersen10-Jun-01 1:55 
Please be aware that you should NOT use OLE2A in a tight loop.

This is will propably crash:
void main()
{
  USES_CONVERSION;
  LPSTR sz="";
  BSTR bstr = L"Goodbye, World...";
  for (int i=0 ; i<100000 ; i++)
    sz = OLE2A(bstr);
}


The reason is that OLE2A allocates memory on the stack for performance reasons, so you will run out of stack space if you do not take care to leave scope once in a while.

Instead, put your OLE2A macro in a separate function, where it is certain that it will not be called several times without leaving scope - or use dynamically allocated mamory (slower but safer).

Christian Skovdal Andersen
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 4:36
professionalAnders Molin9-Jun-01 4:36 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 5:17
Igor Sukhov9-Jun-01 5:17 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 5:22
Igor Sukhov9-Jun-01 5:22 
GeneralRe: Convert ... Pin
9-Jun-01 5:29
suss9-Jun-01 5:29 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 6:09
professionalAnders Molin9-Jun-01 6:09 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 6:36
Igor Sukhov9-Jun-01 6:36 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 7:20
professionalAnders Molin9-Jun-01 7:20 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 8:33
Hadi Rezaee9-Jun-01 8:33 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 8:56
professionalAnders Molin9-Jun-01 8:56 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 9:14
Hadi Rezaee9-Jun-01 9:14 
GeneralRe: Convert ... Pin
Igor Sukhov9-Jun-01 9:39
Igor Sukhov9-Jun-01 9:39 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 10:03
professionalAnders Molin9-Jun-01 10:03 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 10:01
professionalAnders Molin9-Jun-01 10:01 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 21:05
Hadi Rezaee9-Jun-01 21:05 
GeneralRe: Convert ... Pin
Anders Molin9-Jun-01 22:56
professionalAnders Molin9-Jun-01 22:56 
GeneralRe: Convert ... Pin
Hadi Rezaee9-Jun-01 23:46
Hadi Rezaee9-Jun-01 23:46 
GeneralDatabase question ... Pin
Hadi Rezaee8-Jun-01 20:46
Hadi Rezaee8-Jun-01 20:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.