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 err;
int nkeys;
lam_info_entry_t *iterator;
err = lam_info_get_nkeys (info, &nkeys);
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
nkeys > 0;
nkeys--) {
NULL != iterator;
iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
err = lam_info_set(*newinfo, iterator->ie_key, iterator->ie_value);
if (MPI_SUCCESS != err) {
return err;
}
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
}
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) {
lam_info_entry_t *iterator;
int nkeys;
int err;
lam_info_entry_t *trailer_iterator;
err = lam_info_get_nkeys(*info, &nkeys);
/*
* We could just get each element from the list and then call
* 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.
*/
for (iterator = (lam_info_entry_t *)lam_list_get_first(&((*info)->super));
nkeys > 0;
nkeys--) {
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
OBJ_RELEASE(iterator->super.lam_list_prev);
NULL != iterator;
iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
trailer_iterator = (lam_info_entry_t *)lam_get_prev(iterator);
OBJ_RELEASE(trailer_iterator);
}
/*
* 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,
char *key) {
lam_info_entry_t *iterator;
int nkeys;
/* Iterate over all the entries. If the key is found, then
* return immediately. Else, the loop will fall of the edge
* and NULL is returned
*/
nkeys = lam_list_get_size(&(info->super));
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
nkeys > 0;
nkeys--) {
NULL != iterator;
iterator = (lam_info_entry_t *)lam_list_get_next(iterator)) {
if (0 == strcmp(key, iterator->ie_key)) {
return iterator;
}
iterator = (lam_info_entry_t *)iterator->super.lam_list_next;
}
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
*/
iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
for ( ; n > 0; n--) {
iterator = (lam_info_entry_t *)
iterator->super.lam_list_next;
for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super));
n > 0;
n--) {
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