in Platform Packages by
Hi All, we have discovered if we pass a pointer to a empty string, i.e. "" (but still null terminated) results in garbage coming back. We think this is a bug in the library code, because we would expect a empty string to be returned.

Is this a bug, or are we doing something wrong, is there a fix or a workaround if it is a issue?

1 Answer

0 votes


if the source ANSI string was an empty string (""), the function EwNewStringAnsi() returns the value NULL, which in Embedded Wizard is valid to represent an empty string. See also the section Be careful when exchanging strings.

Best regards

Paul Banach

We don't seem to be getting that behavoiur, for example we have a native C method which is pulling some string data in from a C side structure and assigning it to a chora side string, so our code is like this(with names changed for simplicity)

EwRetainString(&_this->ChoraSideStructure->ChoraSideString, EwNewStringAnsi(CSideStructure->CSideString));

In this situation, CSideStructure->CSideString is a empty string "", but we end up with a load of rubbish in the ChoraSideString.

What is the correct way to handle this situation?


I suppose, the CSideStructure->CSideString is not really empty. The implementation of EwNewStringAnsi() checks the given string whether it is empty or not and in the first case returns NULL. I just verified this in a simple example.

To be sure you can add following condition to your code:

if ( CSideStructure->CSideString && *CSideStructure->CSideString )
  EwRetainString( &_this->ChoraSideStructure->ChoraSideString, 
                  EwNewStringAnsi( CSideStructure->CSideString ));

Does the additional condition help? If not, the ANSI C string is not empty.

Another idea: are you using multiple threads in your projects? If yes, do you perform the above operation in context of a thread other than the GUI thread?

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint