Changeset d8d8f20
- Timestamp:
- Jul 21, 2020, 11:18:26 AM (5 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:
- 4a32319
- Parents:
- 2b23d78
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r2b23d78 rd8d8f20 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jul 20 19:04:33202013 // Update Count : 47 212 // Last Modified On : Tue Jul 21 07:58:05 2020 13 // Update Count : 475 14 14 // 15 15 … … 163 163 T * alloc_set( T ptr[], size_t dim, char fill ) { // realloc array with fill 164 164 size_t osize = malloc_size( ptr ); // current allocation 165 T * nptr = realloc( ptr, dim * sizeof(T) ); // CFA realloc166 size_t nsize = malloc_size( nptr ); // new allocation165 size_t nsize = dim * sizeof(T); // new allocation 166 T * nptr = realloc( ptr, nsize ); // CFA realloc 167 167 if ( nsize > osize ) { // larger ? 168 168 memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage … … 172 172 173 173 T * alloc_set( T ptr[], size_t dim, T & fill ) { // realloc array with fill 174 size_t odim = malloc_size( ptr ) / sizeof(T); // current allocation 175 T * nptr = realloc( ptr, dim * sizeof(T) ); // CFA realloc 176 size_t ndim = malloc_size( nptr ) / sizeof(T); // new allocation 174 size_t odim = malloc_size( ptr ) / sizeof(T); // current dimension 175 size_t nsize = dim * sizeof(T); // new allocation 176 size_t ndim = nsize / sizeof(T); // new dimension 177 T * nptr = realloc( ptr, nsize ); // CFA realloc 177 178 if ( ndim > odim ) { // larger ? 178 179 for ( i; odim ~ ndim ) { … … 230 231 T * alloc_align_set( T ptr[], size_t align, size_t dim, char fill ) { 231 232 size_t osize = malloc_size( ptr ); // current allocation 232 T * nptr = realloc( ptr, align, dim * sizeof(T) ); // CFA realloc233 size_t nsize = malloc_size( nptr ); // new allocation233 size_t nsize = dim * sizeof(T); // new allocation 234 T * nptr = realloc( ptr, align, nsize ); // CFA realloc 234 235 if ( nsize > osize ) { // larger ? 235 236 memset( (char *)nptr + osize, (int)fill, nsize - osize ); // initialize added storage … … 239 240 240 241 T * alloc_align_set( T ptr[], size_t align, size_t dim, T & fill ) { 241 size_t odim = malloc_size( ptr ) / sizeof(T); // current allocation 242 T * nptr = realloc( ptr, align, dim * sizeof(T) ); // CFA realloc 243 size_t ndim = malloc_size( nptr ); // new allocation 242 size_t odim = malloc_size( ptr ) / sizeof(T); // current dimension 243 size_t nsize = dim * sizeof(T); // new allocation 244 size_t ndim = nsize / sizeof(T); // new dimension 245 T * nptr = realloc( ptr, align, nsize ); // CFA realloc 244 246 if ( ndim > odim ) { // larger ? 245 247 for ( i; odim ~ ndim ) {
Note: See TracChangeset
for help on using the changeset viewer.