#endif
};
-#ifdef DEBUG
+#ifdef STATIC_CHECKER
struct data_stack_frame {
- int dummy;
+ unsigned int id;
};
#endif
-data_stack_frame_t data_stack_frame = 0;
+unsigned int data_stack_frame_id = 0;
static bool data_stack_initialized = FALSE;
static data_stack_frame_t root_frame_id;
(void)marker; /* only used for debugging */
#endif
- return data_stack_frame++;
+#ifndef STATIC_CHECKER
+ return data_stack_frame_id++;
+#else
+ struct data_stack_frame *frame = i_new(struct data_stack_frame, 1);
+ frame->id = data_stack_frame_id++;
+ return frame;
+#endif
}
data_stack_frame_t t_push_named(const char *format, ...)
frame_block->prev = unused_frame_blocks;
unused_frame_blocks = frame_block;
}
- if (unlikely(--data_stack_frame != *id))
+#ifndef STATIC_CHECKER
+ if (unlikely(--data_stack_frame_id != *id))
return FALSE;
*id = 0;
+#else
+ unsigned int frame_id = (*id)->id;
+ i_free_and_null(*id);
+
+ if (unlikely(--data_stack_frame_id != frame_id))
+ return FALSE;
+#endif
return TRUE;
}
return;
}
data_stack_initialized = TRUE;
- data_stack_frame = (data_stack_frame_t)1;
+ data_stack_frame_id = 1;
outofmem_area.block.size = outofmem_area.block.left =
sizeof(outofmem_area) - sizeof(outofmem_area.block);
overflows.
*/
-#ifndef DEBUG
+#ifndef STATIC_CHECKER
typedef unsigned int data_stack_frame_t;
#else
typedef struct data_stack_frame *data_stack_frame_t;
#endif
-extern data_stack_frame_t data_stack_frame;
+extern unsigned int data_stack_frame_id;
/* All t_..() allocations between t_push*() and t_pop() are freed after t_pop()
is called. Returns the current stack frame number, which can be used
struct pool pool;
int refcount;
- data_stack_frame_t data_stack_frame;
+ unsigned int data_stack_frame;
};
pool_t pool_datastack_create(void)
dpool = t_new(struct datastack_pool, 1);
dpool->pool = static_data_stack_pool;
dpool->refcount = 1;
- dpool->data_stack_frame = data_stack_frame;
+ dpool->data_stack_frame = data_stack_frame_id;
return &dpool->pool;
}
{
struct datastack_pool *dpool = (struct datastack_pool *) pool;
- if (unlikely(dpool->data_stack_frame != data_stack_frame))
+ if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_ref(): stack frame changed");
dpool->refcount++;
{
struct datastack_pool *dpool = (struct datastack_pool *)*pool;
- if (unlikely(dpool->data_stack_frame != data_stack_frame))
+ if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_unref(): stack frame changed");
dpool->refcount--;
if (unlikely(size == 0 || size > SSIZE_T_MAX))
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", size);
- if (unlikely(dpool->data_stack_frame != data_stack_frame))
+ if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_malloc(): stack frame changed");
return t_malloc0(size);
{
struct datastack_pool *dpool = (struct datastack_pool *) pool;
- if (unlikely(dpool->data_stack_frame != data_stack_frame))
+ if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_free(): stack frame changed");
}
if (unlikely(new_size == 0 || new_size > SSIZE_T_MAX))
i_panic("Trying to allocate %"PRIuSIZE_T" bytes", new_size);
- if (unlikely(dpool->data_stack_frame != data_stack_frame))
+ if (unlikely(dpool->data_stack_frame != data_stack_frame_id))
i_panic("pool_data_stack_realloc(): stack frame changed");
if (mem == NULL)