Changeset 102a729 in mainline for uspace/lib/posix/stdlib.c


Ignore:
Timestamp:
2011-07-20T19:43:22Z (14 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4cf8ca6
Parents:
087c8798
Message:

Various bugfixes in stdlib.h functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/posix/stdlib.c

    r087c8798 r102a729  
    4040
    4141#include "errno.h"
     42#include "limits.h"
    4243
    4344#include "libc/sort.h"
     
    138139{
    139140        int (*compare)(const void *, const void *) = userdata;
    140         return compare(elem1, elem2);
     141        int ret = compare(elem1, elem2);
     142       
     143        /* Native qsort internals expect this. */
     144        if (ret < 0) {
     145                return -1;
     146        } else if (ret > 0) {
     147                return 1;
     148        } else {
     149                return 0;
     150        }
    141151}
    142152
     
    353363void *posix_realloc(void *ptr, size_t size)
    354364{
    355         return realloc(ptr, size);
     365        if (ptr != NULL && size == 0) {
     366                /* Native realloc does not handle this special case. */
     367                free(ptr);
     368                return NULL;
     369        } else {
     370                return realloc(ptr, size);
     371        }
    356372}
    357373
Note: See TracChangeset for help on using the changeset viewer.