1
1

initialize free lists correctly

This commit was SVN r1006.
Этот коммит содержится в:
Tim Woodall 2004-03-31 16:58:40 +00:00
родитель 66209260b9
Коммит e20000098e
3 изменённых файлов: 18 добавлений и 12 удалений

Просмотреть файл

@ -221,13 +221,17 @@
* @param object Pointer to the object
* @param type The object type
*/
#define OBJ_CONSTRUCT(object, type) \
OBJ_CONSTRUCT_INTERNAL(object, OBJ_CLASS(type))
#define OBJ_CONSTRUCT_INTERNAL(object, type) \
do { \
if (0 == OBJ_CLASS(type)->cls_initialized) { \
lam_class_initialize(OBJ_CLASS(type)); \
if (0 == (type)->cls_initialized) { \
lam_class_initialize((type)); \
} \
if (object) { \
((lam_object_t *) (object))->obj_class = OBJ_CLASS(type); \
((lam_object_t *) (object))->obj_class = (type); \
((lam_object_t *) (object))->obj_reference_count = 1; \
lam_obj_run_constructors((lam_object_t *) (object)); \
} \

Просмотреть файл

@ -19,10 +19,18 @@ lam_class_t lam_free_list_t_class = {
static void lam_free_list_construct(lam_free_list_t* fl)
{
OBJ_CONSTRUCT(&fl->fl_lock, lam_mutex_t);
fl->fl_max_to_alloc = 0;
fl->fl_num_allocated = 0;
fl->fl_num_per_alloc = 0;
fl->fl_elem_size = 0;
fl->fl_elem_class = 0;
fl->fl_allocator = 0;
}
static void lam_free_list_destruct(lam_free_list_t* fl)
{
OBJ_DESTRUCT(&fl->fl_lock);
}
int lam_free_list_init(
@ -61,10 +69,7 @@ int lam_free_list_grow(lam_free_list_t* flist, size_t num_elements)
for(i=0; i<num_elements; i++) {
lam_list_item_t* item = (lam_list_item_t*)ptr;
if (NULL != flist->fl_elem_class) {
/* bypass OBJ_CONSTRUCT() in this case (generic types) */
((lam_object_t *) item)->obj_class = flist->fl_elem_class;
((lam_object_t *) item)
->obj_class->cls_construct((lam_object_t *) item);
OBJ_CONSTRUCT_INTERNAL(item, flist->fl_elem_class);
}
lam_list_append(&flist->super, item);
ptr += flist->fl_elem_size;

Просмотреть файл

@ -451,10 +451,7 @@ static int lam_free_lists_create_more_elts(lam_free_lists_t *flist, int pool_idx
current_loc = (char *) ptr;
for (desc = 0; desc < flist->fl_elt_per_chunk; desc++)
{
/* bypass OBJ_CONSTRUCT() in this case (generic types) */
((lam_object_t *) current_loc)->obj_class = flist->fl_elt_cls;
((lam_object_t *) current_loc)
->obj_class->cls_construct((lam_object_t *) current_loc);
OBJ_CONSTRUCT_INTERNAL(current_loc, flist->fl_elt_cls);
current_loc += flist->fl_elt_size;
}