File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,25 @@ static void test_alloca(void) {
1919 assert_se (!memcmp (t , zero , 997 ));
2020}
2121
22+ static void test_GREEDY_REALLOC (void ) {
23+ _cleanup_free_ int * a = NULL , * b = NULL ;
24+ size_t n_allocated = 0 , i ;
25+
26+ /* Give valgrind a chance to verify our realloc operations */
27+
28+ for (i = 0 ; i < 2048 ; i ++ ) {
29+ assert_se (GREEDY_REALLOC (a , n_allocated , i + 1 ));
30+ a [i ] = i ;
31+ assert_se (GREEDY_REALLOC (a , n_allocated , i / 2 ));
32+ }
33+
34+ for (i = 30 , n_allocated = 0 ; i < 2048 ; i += 7 ) {
35+ assert_se (GREEDY_REALLOC (b , n_allocated , i + 1 ));
36+ b [i ] = i ;
37+ assert_se (GREEDY_REALLOC (b , n_allocated , i / 2 ));
38+ }
39+ }
40+
2241static void test_memdup_multiply_and_greedy_realloc (void ) {
2342 int org [] = {1 , 2 , 3 };
2443 _cleanup_free_ int * dup ;
@@ -74,6 +93,7 @@ static void test_bool_assign(void) {
7493
7594int main (int argc , char * argv []) {
7695 test_alloca ();
96+ test_GREEDY_REALLOC ();
7797 test_memdup_multiply_and_greedy_realloc ();
7898 test_bool_assign ();
7999
You can’t perform that action at this time.
0 commit comments