tests/test_string.c

changeset 809
b7e2e1d7ed22
parent 806
e06249e09f99
child 890
54565fd74e74
equal deleted inserted replaced
808:f7f193893894 809:b7e2e1d7ed22
177 cxstring str = CX_STR("find the match in this string"); 177 cxstring str = CX_STR("find the match in this string");
178 178
179 size_t const longstrpatternlen = 64 + cx_strstr_sbo_size; 179 size_t const longstrpatternlen = 64 + cx_strstr_sbo_size;
180 size_t const longstrlen = 320 + longstrpatternlen + 14; 180 size_t const longstrlen = 320 + longstrpatternlen + 14;
181 181
182 char *longstrc = malloc(longstrlen+1); 182 // it is more expensive to use calloc here, because we will overwrite
183 char *longstrpatternc = malloc(longstrpatternlen+1); 183 // the memory anyway in the test preparation - but it is more reliable
184 // in case we are doing something horribly wrong
185 char *longstrc = calloc(longstrlen+1, 1);
186 char *longstrpatternc = calloc(longstrpatternlen+1, 1);
184 187
185 memcpy(longstrc, 188 memcpy(longstrc,
186 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl" 189 "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl"
187 "mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx" 190 "mnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx"
188 "yzabcdeababababnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij" 191 "yzabcdeababababnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghij"

mercurial