Thanks - makes sense! Appreciate the explanation - should have looked more closely that early in the morning before asking. Definitely a "2-cups of coffee" question... :-)
On 7/20/07 9:15 AM, "George Bosilca" <bosi...@cs.utk.edu> wrote: > The problem started with the compiler complaining about using a non > initialized variable. When I looked into the code, I just planned to > initialize it with some default value to make the compiler stop > complaining. But then I realize that all the ifs between the moment > where this buffer get initialized and the moment where it get freed, > have to release it before calling return (error cases). So my choices > were: either to add ifs around all these OBJ_RELEASE or to move the > allocation outside the if, in such a way that everybody can safely > release it. I choose the approach that have a minimum impact in > number of lines of code (I'm not a fanatic of copy & paste). It's > definitively not a performance critical code, so one more memory > allocation will have a zero impact. > > george. > > On Jul 20, 2007, at 7:32 AM, Ralph Castain wrote: > >> I guess I really don't understand this change. How is it better that I >> *always* malloc a buffer that I might never use, just so I can >> *always* >> release it - versus *only* malloc'ing and releasing a buffer when I >> know I >> need it?? >> >> I don't really care, but this seems kinda wasteful and I would like to >> understand the benefit. >> >> Thanks >> Ralph >> >> >> >> On 7/19/07 10:06 PM, "bosi...@osl.iu.edu" <bosi...@osl.iu.edu> wrote: >> >>> Author: bosilca >>> Date: 2007-07-20 00:06:39 EDT (Fri, 20 Jul 2007) >>> New Revision: 15533 >>> URL: https://svn.open-mpi.org/trac/ompi/changeset/15533 >>> >>> Log: >>> Always release the buffer (this imply the buffer has to be created >>> outside the special case). >>> >>> Text files modified: >>> trunk/orte/orted/orted_main.c | 6 ++++-- >>> 1 files changed, 4 insertions(+), 2 deletions(-) >>> >>> Modified: trunk/orte/orted/orted_main.c >>> ===================================================================== >>> ========= >>> --- trunk/orte/orted/orted_main.c (original) >>> +++ trunk/orte/orted/orted_main.c 2007-07-20 00:06:39 EDT (Fri, 20 >>> Jul 2007) >>> @@ -391,8 +391,8 @@ >>> } >>> >>> /* if we are not a seed, prep a return buffer to say we >>> started okay */ >>> + buffer = OBJ_NEW(orte_buffer_t); >>> if (!orte_process_info.seed) { >>> - buffer = OBJ_NEW(orte_buffer_t); >>> if (ORTE_SUCCESS != (ret = orte_dss.pack(buffer, &zero, 1, >>> ORTE_INT))) { >>> ORTE_ERROR_LOG(ret); >>> OBJ_RELEASE(buffer); >>> @@ -459,6 +459,7 @@ >>> if (ORTE_SUCCESS != (ret = orte_ns.get_jobid_string >>> (&jobidstring, >>> >>> orte_process_info.my_name))) { >>> ORTE_ERROR_LOG(ret); >>> + OBJ_RELEASE(buffer); >>> return ret; >>> } >>> >>> @@ -509,6 +510,7 @@ >>> ORTE_RML_NON_PERSISTENT, >>> orte_daemon_recv_gate, NULL); >>> if (ret != ORTE_SUCCESS && ret != ORTE_ERR_NOT_IMPLEMENTED) { >>> ORTE_ERROR_LOG(ret); >>> + OBJ_RELEASE(buffer); >>> return ret; >>> } >>> >>> @@ -547,8 +549,8 @@ >>> OBJ_RELEASE(buffer); >>> return ret; >>> } >>> - OBJ_RELEASE(buffer); /* done with this */ >>> } >>> + OBJ_RELEASE(buffer); /* done with this */ >>> >>> if (orte_debug_daemons_flag) { >>> opal_output(0, "%s orted: up and running - waiting for >>> commands!", >>> ORTE_NAME_PRINT(orte_process_info.my_name)); >>> _______________________________________________ >>> svn mailing list >>> s...@open-mpi.org >>> http://www.open-mpi.org/mailman/listinfo.cgi/svn >> >> >> _______________________________________________ >> devel mailing list >> de...@open-mpi.org >> http://www.open-mpi.org/mailman/listinfo.cgi/devel > > _______________________________________________ > devel mailing list > de...@open-mpi.org > http://www.open-mpi.org/mailman/listinfo.cgi/devel