From 68407587ba598a09ac6f63458a080040eeaaf7a9 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Wed, 22 Sep 2004 16:05:33 +0000 Subject: [PATCH] * Make it easier to get just the number of peer processes by allowing NULL to be passed for the first argument of ompi_rte_get_peers(). Also cleaned up the documentation for that function. This commit was SVN r2801. --- src/runtime/ompi_rte_pcm.c | 13 ++++++++++++- src/runtime/runtime.h | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/runtime/ompi_rte_pcm.c b/src/runtime/ompi_rte_pcm.c index 6cde592967..8f1a9f9cf5 100644 --- a/src/runtime/ompi_rte_pcm.c +++ b/src/runtime/ompi_rte_pcm.c @@ -142,11 +142,22 @@ ompi_rte_get_self(void) int ompi_rte_get_peers(ompi_process_name_t **peers, size_t *npeers) { + ompi_process_name_t *useless; + ompi_process_name_t **peers_p; + if (NULL == mca_pcmclient.pcmclient_get_peers) { return OMPI_ERR_NOT_IMPLEMENTED; } - return mca_pcmclient.pcmclient_get_peers(peers, npeers); + if (NULL == peers) { + /* the returned value is a pointer to a static buffer, so no + free is neeeded. This is therefore completely safe. Yay */ + peers_p = &useless; + } else { + peers_p = peers; + } + + return mca_pcmclient.pcmclient_get_peers(peers_p, npeers); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index eee5d5f4ce..eb7acc1d03 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -212,8 +212,22 @@ extern "C" { /** * Get names of peer processes which have been launched * - * @param Nothing - * @return An array of peer names, including me + * @param peers (OUT) Pointer to a pointer of + * ompi_process_name_t. \c *peers will be set + * to point to a statically allocated buffer + * containing the array of peer processes + * started with the current process. If \c + * peers is NULL, then only \c npeers is + * updated. + * @param npeers (OUT) pointer to an integer that will be updated + * with the total number of peers started with + * the current process. Also the length of \c + * *peers array if \c peers is not \c NULL + * + * @return OMPI_SUCCESS on success + * OMPI_ERR_NOT_IMPLEMENTED if the underlying module is + * not properly loaded. + * */ int ompi_rte_get_peers(ompi_process_name_t **peers, size_t *npeers);