1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wall" } */
4 typedef long unsigned int size_t;
5 extern void *realloc (void *__ptr
, size_t __size
)
6 __attribute__ ((__nothrow__
, __leaf__
)) __attribute__ ((__warn_unused_result__
)) __attribute__ ((__alloc_size__ (2)));
7 struct vector_objective
;
8 typedef struct vector_objective vector_objective
;
9 struct vector_objective
{ double *_begin
; double *_end
; double *_capacity
; };
10 static inline size_t vector_objective_size(const vector_objective
* v
) {
11 return v
->_end
- v
->_begin
; /* { dg-bogus "used after" } */
13 static inline size_t vector_objective_capacity(const vector_objective
* v
) {
14 return v
->_capacity
- v
->_begin
;
16 static inline void vector_objective_reserve(vector_objective
* v
, size_t n
) {
17 size_t old_capacity
= vector_objective_capacity(v
);
18 size_t old_size
= vector_objective_size(v
);
19 if (n
> old_capacity
) {
20 v
->_begin
= realloc(v
->_begin
, sizeof(double) * n
);
21 v
->_end
= v
->_begin
+ old_size
;
22 v
->_capacity
= v
->_begin
+ n
;
25 static inline void vector_objective_push_back(vector_objective
* v
, double x
) {
26 if (v
->_end
== v
->_capacity
)
27 vector_objective_reserve (v
, (vector_objective_capacity (v
) == 0) ? 8 : 2 * vector_objective_capacity (v
));
37 rectangle_add(eaf_polygon_t
* regions
, double lx
)
39 vector_objective_push_back(®ions
->xy
, lx
);