Changes in libcfa/src/stdlib.cfa [76e2113:cfbc703d]
- File:
-
- 1 edited
-
libcfa/src/stdlib.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.cfa
r76e2113 rcfbc703d 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Apr 16 22:43:33202013 // Update Count : 49 812 // Last Modified On : Tue Mar 31 13:26:46 2020 13 // Update Count : 495 14 14 // 15 15 … … 37 37 } // alloc_set 38 38 39 T * alloc_set( T ptr[], size_t dim, T fill ) { // realloc array with fill39 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; malloc_size( ptr ) / sizeof(T) ~ dim ) { 45 memcpy( &ptr[i], &fill, sizeof(T) ); // initialize with fill value 46 } // for 44 for ( i; dim ) { memcpy( &ptr[i], &fill, sizeof(T) ); } // initialize with fill value 47 45 } // if 48 46 return (T *)nptr;
Note:
See TracChangeset
for help on using the changeset viewer.