#include <string.h>
#include <stdlib.h>
-#ifndef __WXMSW__
-#include <errno.h>
-#endif
-
#ifdef __SALFORDC__
#include <clib.h>
#endif
if ( pData->IsEmpty() ) {
nLen += EXTRA_ALLOC;
- wxStringData* pData = (wxStringData*)
- malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar));
+ pData = (wxStringData *)
+ malloc(sizeof(wxStringData) + (nLen + 1)*sizeof(wxChar));
if ( pData == NULL ) {
// allocation failure handled by caller
for ( ;; )
{
wxStringBuffer tmp(*this, size + 1);
- wxChar* buf = tmp;
+ wxChar *buf = tmp;
if ( !buf )
{
// vsnprintf() may return either -1 (traditional Unix behaviour) or the
// total number of characters which would have been written if the
- // buffer were large enough
- if ( len >= 0 && len <= size )
+ // buffer were large enough (newer standards such as Unix98)
+ if ( len < 0 )
{
- // ok, there was enough space
- break;
+ // still not enough, as we don't know how much we need, double the
+ // current size of the buffer
+ size *= 2;
}
-
-#ifdef EOVERFLOW
- // if the error is not due to not having enough space (it could be e.g.
- // EILSEQ), break too -- we'd just eat all available memory uselessly
- if ( errno != EOVERFLOW )
+ else if ( len > size )
+ {
+ size = len;
+ }
+ else // ok, there was enough space
{
- // no sense in continuing
break;
}
-#endif // EOVERFLOW
-
- // still not enough, double it again
- size *= 2;
}
// we could have overshot
END_SORT();
}
-typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, const void *second);
+extern "C"
+{
+ typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first,
+ const void *second);
+}
void wxArrayString::Sort(CompareFunction2 compareFunction)
{