fixing logic for lowest_free and number_free
This commit was SVN r2630.
Этот коммит содержится в:
родитель
57ceb5225e
Коммит
64e983a88a
@ -120,8 +120,8 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr)
|
|||||||
OMPI_THREAD_UNLOCK(&(table->lock));
|
OMPI_THREAD_UNLOCK(&(table->lock));
|
||||||
return OMPI_ERROR;
|
return OMPI_ERROR;
|
||||||
}
|
}
|
||||||
table->lowest_free = table->size;
|
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->size *= TABLE_GROW;
|
||||||
table->addr = p;
|
table->addr = p;
|
||||||
for (i = table->lowest_free; i < table->size; i++) {
|
for (i = table->lowest_free; i < table->size; i++) {
|
||||||
@ -213,27 +213,56 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index,
|
|||||||
/*
|
/*
|
||||||
* allow a specific index to be changed.
|
* allow a specific index to be changed.
|
||||||
*/
|
*/
|
||||||
table->addr[index] = value;
|
|
||||||
/* mark element as free, if NULL element */
|
if ( NULL == table->addr[index] ) {
|
||||||
if( NULL == value ) {
|
table->addr[index] = value;
|
||||||
if (index < table->lowest_free) {
|
/* mark element as free, if NULL element */
|
||||||
table->lowest_free = index;
|
if( NULL == value ) {
|
||||||
}
|
if (index < table->lowest_free) {
|
||||||
table->number_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 {
|
else {
|
||||||
/* Reset lowest_free if required */
|
table->addr[index] = value;
|
||||||
if ( index == table->lowest_free ) {
|
/* mark element as free, if NULL element */
|
||||||
size_t i;
|
if( NULL == value ) {
|
||||||
|
if (index < table->lowest_free) {
|
||||||
|
table->lowest_free = index;
|
||||||
|
}
|
||||||
|
table->number_free++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* 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;
|
||||||
if ( NULL == table->addr[i] ){
|
for ( i=index; i<table->size; i++) {
|
||||||
table->lowest_free = i;
|
if ( NULL == table->addr[i] ){
|
||||||
break;
|
table->lowest_free = i;
|
||||||
}
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
ompi_output(0,"ompi_pointer_array_set_item: OUT: "
|
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.
|
* allow a specific index to be changed.
|
||||||
*/
|
*/
|
||||||
table->addr[index] = value;
|
table->addr[index] = value;
|
||||||
|
table->number_free--;
|
||||||
/* Reset lowest_free if required */
|
/* Reset lowest_free if required */
|
||||||
if ( index == table->lowest_free ) {
|
if ( index == table->lowest_free ) {
|
||||||
size_t i;
|
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] ){
|
if ( NULL == table->addr[i] ){
|
||||||
table->lowest_free = i;
|
table->lowest_free = i;
|
||||||
break;
|
break;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user