Ignore:
Timestamp:
12/01/20 01:11:25 (4 years ago)
Author:
Maciej Komosinski
Message:

Use qsort_r() substitute when not available (Android)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/vm/classes/collectionobj.cpp

    r931 r1041  
    272272#ifdef QSORT_R_USING_QSORT_S
    273273        static int compare(void* _this, const void *a, const void *b);
     274        bool operator()(const ExtValue *a, const ExtValue *b) { return compare(this,&a,&b) == ExtValue::ResultLower; }
    274275#else
    275276        static int compare(const void *a, const void *b, void* _this);
     277        bool operator()(const ExtValue *a, const ExtValue *b) { return compare(&a,&b,this) == ExtValue::ResultLower; }
    276278#endif
    277279};
     
    319321                //However, std::sort() requires "strict weak ordering" and may crash (and indeed crashes, "undefined behavior") when given a non-compliant comparator.
    320322                //We use qsort() instead because we can't control what kind of user script comparator function will be passed to Vector.sort(), and qsort() seems to behave safely for every function.
     323#ifdef __ANDROID__
     324                std::sort(first, first + data.size(), cmp); //no qsort_r() or equivalent on Android (yet)
     325#else
    321326                qsort_r(first, data.size(), sizeof(ExtValue*), cmp.compare, &cmp);
     327#endif
    322328        }
    323329        else
Note: See TracChangeset for help on using the changeset viewer.