/* * APP CONTEXT */ int orte_dt_size_app_context(size_t *size, orte_app_context_t *src, opal_data_type_t type) { /* account for the object itself */ *size = sizeof(orte_app_context_t); /* if src is NULL, then that's all we wanted */ if (NULL == src) return ORTE_SUCCESS; if (NULL != src->app) { *size += strlen(src->app); } *size += opal_argv_len(src->argv); *size += opal_argv_len(src->env); if (NULL != src->cwd) { *size += strlen(src->cwd); /* working directory */ } if (NULL != src->hostfile) { *size += strlen(src->hostfile); /* hostfile name */ } if (NULL != src->add_hostfile) { *size += strlen(src->add_hostfile); /* add_hostfile name */ } *size += opal_argv_len(src->add_host); *size += opal_argv_len(src->dash_host); if (NULL != src->prefix_dir) { *size += strlen(src->prefix_dir); } return ORTE_SUCCESS; }
static bool test7(void) { char *a[] = { "a", "b", "c", NULL }; size_t a_len = (1 + 1 + sizeof(char *)) * 3 + sizeof(char **); /* check a NULL pointer first -- should return 0 */ if (opal_argv_len(NULL) != (size_t) 0) { return false; } /* now check a real string */ /* size should be (sizeof(char **) + (sizeof(char) + sizeof('\0') + sizeof(char*)) * 3) */ if (opal_argv_len(a) != a_len) { return false; } /* All done */ return true; }