- Timestamp:
- Jan 18, 2021, 2:55:08 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- e35a32b
- Parents:
- 978e5eb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/stdlib.hfa
r978e5eb r3d3d75e 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Dec 12 13:52:34 202013 // Update Count : 5 3612 // Last Modified On : Sat Jan 16 09:07:10 2021 13 // Update Count : 568 14 14 // 15 15 … … 163 163 S_fill(T) ret = { 't' }; 164 164 size_t size = sizeof(T); 165 if(size > sizeof(ret.t)) { printf("ERROR: const object of size greater than 50 bytes given for dynamic memory fill\n"); exit(1); } 165 if ( size > sizeof(ret.t) ) { 166 abort( "ERROR: const object of size greater than 50 bytes given for dynamic memory fill\n" ); 167 } // if 166 168 memcpy( &ret.t, &t, size ); 167 169 return ret; … … 173 175 S_realloc(T) ?`realloc ( T * a ) { return (S_realloc(T)){a}; } 174 176 175 T * $alloc_internal( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill ) {177 T * $alloc_internal( void * Resize, T * Realloc, size_t Align, size_t Dim, S_fill(T) Fill ) { 176 178 T * ptr = NULL; 177 179 size_t size = sizeof(T); … … 181 183 ptr = (T*) (void *) resize( (void *)Resize, Align, Dim * size ); 182 184 } else if ( Realloc ) { 183 if ( Fill.tag != '0') copy_end = min(malloc_size( Realloc ), Dim * size);184 ptr = (T *) (void *) realloc( (void *)Realloc, Align, Dim * size );185 if ( Fill.tag != '0' ) copy_end = min(malloc_size( Realloc ), Dim * size ); 186 ptr = (T *) (void *) realloc( (void *)Realloc, Align, Dim * size ); 185 187 } else { 186 ptr = (T *) (void *) memalign( Align, Dim * size );187 } 188 189 if (Fill.tag == 'c') {188 ptr = (T *) (void *) memalign( Align, Dim * size ); 189 } 190 191 if ( Fill.tag == 'c' ) { 190 192 memset( (char *)ptr + copy_end, (int)Fill.c, Dim * size - copy_end ); 191 } else if (Fill.tag == 't') {193 } else if ( Fill.tag == 't' ) { 192 194 for ( int i = copy_end; i < Dim * size; i += size ) { 193 #pragma GCC diagnostic push 194 #pragma GCC diagnostic ignored "-Warray-bounds" 195 #pragma GCC diagnostic push 196 #pragma GCC diagnostic ignored "-Wstringop-overflow=" 197 memcpy( (char *)ptr + i, &Fill.t, size ); 198 #pragma GCC diagnostic pop 199 #pragma GCC diagnostic pop 195 #pragma GCC diagnostic push 196 #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" 197 memcpy( (char *)ptr + i, &Fill.t, sizeof(Fill.t) ); 198 #pragma GCC diagnostic pop 200 199 } 201 } else if (Fill.tag == 'a') {200 } else if ( Fill.tag == 'a' ) { 202 201 memcpy( (char *)ptr + copy_end, Fill.at, min(Dim * size - copy_end, Fill.size) ); 203 } else if(Fill.tag == 'T') { 204 for ( int i = copy_end; i < Dim * size; i += size ) { 205 memcpy( (char *)ptr + i, Fill.at, size ); 206 } 202 } else if ( Fill.tag == 'T' ) { 203 memcpy( (char *)ptr + copy_end, Fill.at, Dim * size ); 207 204 } 208 205
Note: See TracChangeset
for help on using the changeset viewer.