Changeset 76e2113 for libcfa/src/stdlib.cfa
- Timestamp:
- Apr 18, 2020, 9:08:12 AM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 692e6f1
- Parents:
- 899dfbb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.cfa
r899dfbb r76e2113 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T ue Mar 31 13:26:46202013 // Update Count : 49 512 // Last Modified On : Thu Apr 16 22:43:33 2020 13 // Update Count : 498 14 14 // 15 15 … … 37 37 } // alloc_set 38 38 39 T * alloc_set( T ptr[], size_t dim, T fill ) { 39 T * alloc_set( T ptr[], size_t dim, T fill ) { // realloc array with fill 40 40 size_t olen = malloc_usable_size( ptr ); // current allocation 41 41 void * nptr = (void *)realloc( (void *)ptr, dim * sizeof(T) ); // C realloc 42 42 size_t nlen = malloc_usable_size( nptr ); // new allocation 43 43 if ( nlen > olen ) { // larger ? 44 for ( i; dim ) { memcpy( &ptr[i], &fill, sizeof(T) ); } // initialize with fill value 44 for ( i; malloc_size( ptr ) / sizeof(T) ~ dim ) { 45 memcpy( &ptr[i], &fill, sizeof(T) ); // initialize with fill value 46 } // for 45 47 } // if 46 48 return (T *)nptr;
Note: See TracChangeset
for help on using the changeset viewer.