comparison test/call_suite/globals.c @ 48:dc0bcee2c847

bugfix: value and control-group arrays need to be max-arg size + 1 (... futher cleanup is needed as index 0 in array is not used at all ;-/ )
author Daniel Adler <dadler@dyncall.org>
date Sat, 19 Dec 2015 23:04:42 +0000
parents 3e629dc19168
children f5577f6bf97a
comparison
equal deleted inserted replaced
44:b8f16ad80e34 48:dc0bcee2c847
36 double rand_d() { return ( ( (double) rand() ) / ( (double) RAND_MAX ) ); } 36 double rand_d() { return ( ( (double) rand() ) / ( (double) RAND_MAX ) ); }
37 37
38 void init_K() 38 void init_K()
39 { 39 {
40 int i; 40 int i;
41 #define X(CH,T,QCH) V_##CH = (T*) malloc(sizeof(T)*G_maxargs); K_##CH = (T*) malloc(sizeof(T)*G_maxargs); 41 #define X(CH,T,QCH) V_##CH = (T*) malloc(sizeof(T)*(G_maxargs+1)); K_##CH = (T*) malloc(sizeof(T)*(G_maxargs+1));
42 DEF_TYPES 42 DEF_TYPES
43 #undef X 43 #undef X
44 for(i=0;i<G_maxargs;++i) { 44 for(i=0;i<G_maxargs+1;++i) {
45 K_c[i] = (char) (((rand_d()-0.5)*2) * (1<<7)); 45 K_c[i] = (char) (((rand_d()-0.5)*2) * (1<<7));
46 K_s[i] = (short) (((rand_d()-0.5)*2) * (1<<(sizeof(short)*8-1))); 46 K_s[i] = (short) (((rand_d()-0.5)*2) * (1<<(sizeof(short)*8-1)));
47 K_i[i] = (int) (((rand_d()-0.5)*2) * (1<<(sizeof(int)*8-2))); 47 K_i[i] = (int) (((rand_d()-0.5)*2) * (1<<(sizeof(int)*8-2)));
48 K_j[i] = (long) (((rand_d()-0.5)*2) * (1L<<(sizeof(long)*8-2))); 48 K_j[i] = (long) (((rand_d()-0.5)*2) * (1L<<(sizeof(long)*8-2)));
49 K_l[i] = (long long) (((rand_d()-0.5)*2) * (1LL<<(sizeof(long long)*8-2))); 49 K_l[i] = (long long) (((rand_d()-0.5)*2) * (1LL<<(sizeof(long long)*8-2)));
54 } 54 }
55 55
56 void clear_V() 56 void clear_V()
57 { 57 {
58 int i; 58 int i;
59 for(i=0;i<G_maxargs;++i) { 59 for(i=0;i<G_maxargs+1;++i) {
60 #define X(CH,T,QCH) V_##CH[i] = (T) 0; 60 #define X(CH,T,QCH) V_##CH[i] = (T) 0;
61 DEF_TYPES 61 DEF_TYPES
62 #undef X 62 #undef X
63 } 63 }
64 } 64 }