diff --git a/src/mpi/interface/c/info_delete.c b/src/mpi/interface/c/info_delete.c index 5e87e3e87a..286ca00581 100644 --- a/src/mpi/interface/c/info_delete.c +++ b/src/mpi/interface/c/info_delete.c @@ -27,9 +27,8 @@ * @retval MPI_ERR_NOKEY */ int MPI_Info_delete(MPI_Info info, char *key) { - lam_info_entry_t *search; - lam_info_entry_t *found; int key_length; + int err; /** * This function merely deletes the (key,val) pair in info */ @@ -44,21 +43,11 @@ int MPI_Info_delete(MPI_Info info, char *key) { return MPI_ERR_INFO_KEY; } - search = lam_info_find_key (info, key); + err = lam_info_delete (info, key); - if (NULL == search){ - printf ("Invalid key given\n"); - return MPI_ERR_INFO_NOKEY; - } else { - /* - * An entry with this key value was found. Remove the item - * and free the memory allocated to it - */ - found = (lam_info_entry_t *) - lam_list_remove_item (&(info->super), - (lam_list_item_t *)search); - OBJ_RELEASE(search); + if (MPI_ERR_INFO_NOKEY == err) { + printf ("Invalid Key given\n"); + return err; } - - return MPI_SUCCESS; + return err; } diff --git a/src/mpi/interface/c/info_dup.c b/src/mpi/interface/c/info_dup.c index c7d40e429b..8316419963 100644 --- a/src/mpi/interface/c/info_dup.c +++ b/src/mpi/interface/c/info_dup.c @@ -21,6 +21,7 @@ * * @retval MPI_SUCCESS * @retval MPI_ERR_ARG + * @retval MPI_ERR_SYSRESOURCE * * Not only will the (key, value) pairs be duplicated, the order of keys * will be the same in 'newinfo' as it is in 'info'. @@ -28,9 +29,7 @@ * 'MPI_Info_free'. */ int MPI_Info_dup(MPI_Info info, MPI_Info *newinfo) { - lam_info_entry_t *iterator; int err; - int nkeys; /** * Here we need to do 2 things * 1. Create a newinfo object using MPI_Info_create @@ -54,18 +53,12 @@ int MPI_Info_dup(MPI_Info info, MPI_Info *newinfo) { /* * Now to actually duplicate all the values */ - err = MPI_Info_get_nkeys (info, &nkeys); - - for (iterator = (lam_info_entry_t *)lam_list_get_first(&(info->super)); - nkeys > 0; - nkeys--) { - err = MPI_Info_set (*newinfo, iterator->ie_key, iterator->ie_value); - if (MPI_SUCCESS != err) { - printf ("Failed to set a key in newinfo\n"); - return err; - } - iterator = (lam_info_entry_t *)iterator->super.lam_list_next; - } + err = lam_info_dup (info, newinfo); + if (err == MPI_ERR_SYSRESOURCE) { + printf ("Resources are not sufficient to finish dup'ing\n"); + return err; + } + return MPI_SUCCESS; } diff --git a/src/mpi/interface/c/info_free.c b/src/mpi/interface/c/info_free.c index 38ddde0fac..3fac3818de 100644 --- a/src/mpi/interface/c/info_free.c +++ b/src/mpi/interface/c/info_free.c @@ -24,8 +24,6 @@ * Upon successful completion, 'info' will be set to 'MPI_INFO_NULL'. */ int MPI_Info_free(MPI_Info *info) { - lam_info_entry_t *iterator; - int nkeys; int err; /* * Free all the alloced items from MPI_Info info. @@ -40,30 +38,11 @@ int MPI_Info_free(MPI_Info *info) { } /* - * Now to actually free all the values + * Now call the back end. Once again, it does not look like + * there can be any error from this, but then who knows. Have + * to recheck this part too. */ - err = MPI_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 - * MPI_Info_delete has extra logic to it. So, do the simple - * 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); - } - - /* - * Anju: - * Add things to remove the fortran handle from the mapping table - */ - - OBJ_RELEASE(*info); - *info = MPI_INFO_NULL; + err = lam_info_free (info); return MPI_SUCCESS; } diff --git a/src/mpi/interface/c/info_get.c b/src/mpi/interface/c/info_get.c index cfa6a15ec7..c6fe2e3bba 100644 --- a/src/mpi/interface/c/info_get.c +++ b/src/mpi/interface/c/info_get.c @@ -36,9 +36,8 @@ int MPI_Info_get(MPI_Info info, char *key, int valuelen, char *value, int *flag) { - lam_info_entry_t *search; + int err; int key_length; - int value_length; /* * Simple function. All we need to do is search for the value @@ -56,29 +55,12 @@ int MPI_Info_get(MPI_Info info, char *key, int valuelen, return MPI_ERR_INFO_KEY; } - search = lam_info_find_key (info, key); - - if (NULL == search){ - *flag = 0; - } else { - /* - * We have found the element, so we can return the value - * Set the flag, value_length and value - */ - *flag = 1; - value_length = strlen(search->ie_value); - /* - * If the stored value is shorter than valuelen, then - * we can copy the entire value out. Else, we have to - * copy ONLY valuelen bytes out - */ - if (value_length < valuelen ) { - strcpy(value, search->ie_value); - } else { - lam_strncpy(value, search->ie_value, valuelen); - value[valuelen] = 0; - } - } - + err = lam_info_get (info, key, valuelen, value, flag); + + /* + * Once again, lam_info_get does not return any error. So, as of + * now there is no error condition to check for. But maybe this + * needs to be re-evaluated and then something can be done + */ return MPI_SUCCESS; } diff --git a/src/mpi/interface/c/info_get_nkeys.c b/src/mpi/interface/c/info_get_nkeys.c index 44b094905c..052ae03b8a 100644 --- a/src/mpi/interface/c/info_get_nkeys.c +++ b/src/mpi/interface/c/info_get_nkeys.c @@ -27,12 +27,18 @@ * containing the key-value pairs */ int MPI_Info_get_nkeys(MPI_Info info, int *nkeys) { + int err; if (NULL == info){ printf ("Invalid MPI_Info handle passed\n"); return MPI_ERR_ARG; } - *nkeys = (int) lam_list_get_size(&(info->super)); + err = lam_info_get_nkeys(info, nkeys); + + /* + * check if there are any errors. There does not seem to be any + * error possible in this. But have to look at it again + */ return MPI_SUCCESS; } diff --git a/src/mpi/interface/c/info_get_nthkey.c b/src/mpi/interface/c/info_get_nthkey.c index f5bfb2aa30..4e62d48a89 100644 --- a/src/mpi/interface/c/info_get_nthkey.c +++ b/src/mpi/interface/c/info_get_nthkey.c @@ -25,8 +25,8 @@ * @retval MPI_ERR_ARG */ int MPI_Info_get_nthkey(MPI_Info info, int n, char *key) { - lam_info_entry_t *iterator; int nkeys; + int err; /* * 1. Check if info is a valid handle @@ -45,19 +45,14 @@ int MPI_Info_get_nthkey(MPI_Info info, int n, char *key) { return MPI_ERR_ARG; } else { /* - * Iterate over and over till we get to the nth key + * Everything seems alright. Call the back end key copy */ - 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; - } - /* - * iterator is of the type lam_list_item_t. We have to - * cast it to lam_info_entry_t before we can use it to - * access the value - */ - strcpy(key, iterator->ie_key); + err = lam_info_get_nthkey (info, n, key); } + + /* + * Have to check whether there are any error condditions. It appears + * that there are not too many error conditions from the look of it + */ return MPI_SUCCESS; } diff --git a/src/mpi/interface/c/info_get_valuelen.c b/src/mpi/interface/c/info_get_valuelen.c index c1b9796932..93ae0a9767 100644 --- a/src/mpi/interface/c/info_get_valuelen.c +++ b/src/mpi/interface/c/info_get_valuelen.c @@ -35,8 +35,8 @@ int MPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, int *flag) { - lam_info_entry_t *search; int key_length; + int err; /* * Simple function. All we need to do is search for the value @@ -53,17 +53,11 @@ int MPI_Info_get_valuelen(MPI_Info info, char *key, int *valuelen, return MPI_ERR_INFO_KEY; } - search = lam_info_find_key (info, key); + err = lam_info_get_valuelen (info, key, valuelen, flag); - if (NULL == search){ - *flag = 0; - } else { - /* - * We have found the element, so we can return the value - * Set the flag, value_length and value - */ - *flag = 1; - *valuelen = strlen(search->ie_value); - } - return MPI_SUCCESS; + /* + * Once again, the error problem. lam_info_get_valuelen + * does not have an obvious error return. + */ + return err; } diff --git a/src/mpi/interface/c/info_set.c b/src/mpi/interface/c/info_set.c index 56822d0f2f..6bb00339c7 100644 --- a/src/mpi/interface/c/info_set.c +++ b/src/mpi/interface/c/info_set.c @@ -37,12 +37,9 @@ * and MPI_ERR_INFO_VALUE are raised */ int MPI_Info_set(MPI_Info info, char *key, char *value) { - - lam_info_entry_t *new_info; - lam_info_entry_t *old_info; + int err; int key_length; int value_length; - char *new_value; /* * Error conditions are @@ -74,38 +71,16 @@ int MPI_Info_set(MPI_Info info, char *key, char *value) { } /* - * If all is right with the arguments, then: - * 1. Allocate space for value - * 2. Check if the key was associated with a previous value - * - If so delete that value and store the new value - * 3. Store the (key, value) pair + * If all is right with the arguments, then call the back-end + * allocator. */ + + err = lam_info_set (info, key, value); - new_value = malloc(value_length * sizeof(char)); - if (NULL == new_value) { + if (MPI_ERR_SYSRESOURCE == err) { printf ("Unable to malloc memory for new (key, value) pair\n"); - return MPI_ERR_SYSRESOURCE; - } - - strcpy (new_value, value); - old_info = lam_info_find_key (info, key); - - if (NULL != old_info) { - /* - * key already exists. remove the value associated with it - */ - free(old_info->ie_value); - old_info->ie_value = new_value; - } else { - new_info = OBJ_NEW(lam_info_entry_t); - if (NULL == new_info) { - printf ("Unable to malloc memory for new (key, value) pair\n"); - return MPI_ERR_SYSRESOURCE; - } - strcpy (new_info->ie_key, key); - new_info->ie_value = new_value; - lam_list_append (&(info->super), (lam_list_item_t *) new_info); + return err; } - return MPI_SUCCESS; + return err; }