1
1

fixing logic for lowest_free and number_free

This commit was SVN r2630.
Этот коммит содержится в:
Edgar Gabriel 2004-09-13 15:13:13 +00:00
родитель 57ceb5225e
Коммит 64e983a88a

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

@ -121,7 +121,7 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr)
return OMPI_ERROR;
}
table->lowest_free = table->size;
table->number_free = (TABLE_GROW - 1) * table->size;
table->number_free += (TABLE_GROW - 1) * table->size;
table->size *= TABLE_GROW;
table->addr = p;
for (i = table->lowest_free; i < table->size; i++) {
@ -213,6 +213,32 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index,
/*
* allow a specific index to be changed.
*/
if ( NULL == table->addr[index] ) {
table->addr[index] = value;
/* mark element as free, if NULL element */
if( NULL == value ) {
if (index < table->lowest_free) {
table->lowest_free = index;
}
}
else {
table->number_free--;
/* Reset lowest_free if required */
if ( index == table->lowest_free ) {
size_t i;
table->lowest_free=table->size;
for ( i=index; i<table->size; i++) {
if ( NULL == table->addr[i] ){
table->lowest_free = i;
break;
}
}
}
}
}
else {
table->addr[index] = value;
/* mark element as free, if NULL element */
if( NULL == value ) {
@ -226,7 +252,8 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index,
if ( index == table->lowest_free ) {
size_t i;
for ( i=table->lowest_free; i<table->size; i++) {
table->lowest_free=table->size;
for ( i=index; i<table->size; i++) {
if ( NULL == table->addr[i] ){
table->lowest_free = i;
break;
@ -234,6 +261,8 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index,
}
}
}
}
#if 0
ompi_output(0,"ompi_pointer_array_set_item: OUT: "
@ -305,12 +334,13 @@ int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t in
* allow a specific index to be changed.
*/
table->addr[index] = value;
table->number_free--;
/* Reset lowest_free if required */
if ( index == table->lowest_free ) {
size_t i;
for ( i=table->lowest_free; i<table->size; i++) {
table->lowest_free = table->size;
for ( i=index; i<table->size; i++) {
if ( NULL == table->addr[i] ){
table->lowest_free = i;
break;