1
1

Changing the way I wasy accessing elements inside the list. Previosuly, I was

directly using the next and the previous pointers for navigating inside the 
list. Now, I am changing these to use the lists built-in lists.

This commit was SVN r1019.
Этот коммит содержится в:
Prabhanjan Kambadur 2004-04-08 19:12:16 +00:00
родитель 13a4d3b934
Коммит d4aeacbff9
2 изменённых файлов: 16 добавлений и 22 удалений

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

@ -64,19 +64,15 @@ void lam_info_entry_destruct(lam_info_entry_t *entry) {
*/ */
int lam_info_dup (lam_info_t *info, lam_info_t **newinfo) { int lam_info_dup (lam_info_t *info, lam_info_t **newinfo) {
int err; int err;
int nkeys;
lam_info_entry_t *iterator; lam_info_entry_t *iterator;
err = lam_info_get_nkeys (info, &nkeys);
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super)); for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
nkeys > 0; NULL != iterator;
nkeys--) { iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
err = lam_info_set(*newinfo, iterator->ie_key, iterator->ie_value); err = lam_info_set(*newinfo, iterator->ie_key, iterator->ie_value);
if (MPI_SUCCESS != err) { if (MPI_SUCCESS != err) {
return err; return err;
} }
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
} }
return MPI_SUCCESS; return MPI_SUCCESS;
} }
@ -137,10 +133,8 @@ int lam_info_set (lam_info_t *info, char *key, char *value) {
*/ */
int lam_info_free (lam_info_t **info) { int lam_info_free (lam_info_t **info) {
lam_info_entry_t *iterator; lam_info_entry_t *iterator;
int nkeys; lam_info_entry_t *trailer_iterator;
int err;
err = lam_info_get_nkeys(*info, &nkeys);
/* /*
* We could just get each element from the list and then call * We could just get each element from the list and then call
* MPI_Info_delete. But this causes unnecessary delay because * MPI_Info_delete. But this causes unnecessary delay because
@ -148,10 +142,10 @@ int lam_info_free (lam_info_t **info) {
* remove operation to save time. * remove operation to save time.
*/ */
for (iterator = (lam_info_entry_t *)lam_list_get_first(&((*info)->super)); for (iterator = (lam_info_entry_t *)lam_list_get_first(&((*info)->super));
nkeys > 0; NULL != iterator;
nkeys--) { iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
iterator = (lam_info_entry_t *)iterator->super.lam_list_next; trailer_iterator = (lam_info_entry_t *)lam_get_prev(iterator);
OBJ_RELEASE(iterator->super.lam_list_prev); OBJ_RELEASE(trailer_iterator);
} }
/* /*
* Anju: * Anju:

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

@ -83,20 +83,17 @@ int lam_info_get_valuelen (lam_info_t *info, char *key, int *valuelen,
static inline lam_info_entry_t *lam_info_find_key (lam_info_t *info, static inline lam_info_entry_t *lam_info_find_key (lam_info_t *info,
char *key) { char *key) {
lam_info_entry_t *iterator; lam_info_entry_t *iterator;
int nkeys;
/* Iterate over all the entries. If the key is found, then /* Iterate over all the entries. If the key is found, then
* return immediately. Else, the loop will fall of the edge * return immediately. Else, the loop will fall of the edge
* and NULL is returned * and NULL is returned
*/ */
nkeys = lam_list_get_size(&(info->super));
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super)); for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
nkeys > 0; NULL != iterator;
nkeys--) { iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
if (0 == strcmp(key, iterator->ie_key)) { if (0 == strcmp(key, iterator->ie_key)) {
return iterator; return iterator;
} }
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
} }
return (lam_info_entry_t *)0; return (lam_info_entry_t *)0;
} }
@ -130,10 +127,13 @@ lam_info_get_nthkey (lam_info_t *info, int n, char *key) {
/* /*
* Iterate over and over till we get to the nth key * Iterate over and over till we get to the nth key
*/ */
iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super)); for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
for ( ; n > 0; n--) { n > 0;
iterator = (lam_info_entry_t *) n--) {
iterator->super.lam_list_next; iterator = (lam_info_entry_t *)lam_list_get_next(iterator);
if ( NULL == iterator) {
return MPI_ERR_ARG;
}
} }
/* /*
* iterator is of the type lam_list_item_t. We have to * iterator is of the type lam_list_item_t. We have to