Changeset c354108


Ignore:
Timestamp:
Aug 15, 2020, 12:06:33 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
68d40b7
Parents:
6553828
Message:

change alloc_set with array initialization to have old and new dimension arguments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/stdlib.hfa

    r6553828 rc354108  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Aug 11 21:11:46 2020
    13 // Update Count     : 495
     12// Last Modified On : Fri Aug 14 23:38:50 2020
     13// Update Count     : 504
    1414//
    1515
     
    3939//---------------------------------------
    4040
     41#include "common.hfa"
     42
     43//---------------------------------------
     44
    4145// Macro because of returns
    4246#define $VAR_ALLOC( allocation, alignment ) \
     
    152156        } // alloc_set
    153157
    154         T * alloc_set( size_t dim, const T fill[] ) {
    155                 return (T *)memcpy( (T *)alloc( dim ), fill, dim * sizeof(T) ); // initialize with fill value
     158        T * alloc_set( size_t dimNew, const T fill[], size_t dimOld ) {
     159                return (T *)memcpy( (T *)alloc( dimNew ), fill, min( dimNew, dimOld ) * sizeof(T) ); // initialize with fill value
    156160        } // alloc_set
    157161
     
    220224        } // alloc_align_set
    221225
    222         T * alloc_align_set( size_t align, size_t dim, const T fill[] ) {
    223                 return (T *)memcpy( (T *)alloc_align( align, dim ), fill, dim * sizeof(T) );
     226        T * alloc_align_set( size_t align, size_t dimNew, const T fill[], size_t dimOld ) {
     227                return (T *)memcpy( (T *)alloc_align( align, dimNew ), fill, min( dimNew, dimOld ) * sizeof(T) );
    224228        } // alloc_align_set
    225229
     
    374378//---------------------------------------
    375379
    376 #include "common.hfa"
    377 
    378 //---------------------------------------
    379 
    380380extern bool threading_enabled(void) OPTIONAL_THREAD;
    381381
Note: See TracChangeset for help on using the changeset viewer.