Ignore:
Timestamp:
Apr 16, 2017, 9:16:18 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
33e22da
Parents:
19b2133
Message:

changes to malloc and bsearch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/stdlib.c

    r19b2133 r02d241f  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Apr  1 18:31:26 2017
    13 // Update Count     : 181
     12// Last Modified On : Sun Apr 16 10:41:05 2017
     13// Update Count     : 189
    1414//
    1515
     
    7878} // posix_memalign
    7979
    80 forall( dtype T, ttype Params | sized(T) | { void ?{}(T *, Params); } )
     80forall( dtype T, ttype Params | sized(T) | { void ?{}( T *, Params ); } )
    8181T * new( Params p ) {
    82         return ((T*)malloc()){ p };
     82        return ((T *)malloc()){ p };
    8383}
    8484
     
    229229forall( otype T | { int ?<?( T, T ); } )
    230230unsigned int bsearch( T key, const T * arr, size_t dimension ) {
    231         int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
    232         T *result = (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
     231        T *result = bsearch( key, arr, dimension );
    233232        return result ? result - arr : dimension;                       // pointer subtraction includes sizeof(T)
    234233} // bsearch
Note: See TracChangeset for help on using the changeset viewer.