Esempio n. 1
0
opal_hwloc_print_buffers_t *opal_hwloc_get_print_buffer(void)
{
    opal_hwloc_print_buffers_t *ptr;
    int ret, i;
    
    if (!fns_init) {
        /* setup the print_args function */
        if (OPAL_SUCCESS != (ret = opal_tsd_key_create(&print_tsd_key, buffer_cleanup))) {
            return NULL;
        }
        fns_init = true;
    }
    
    ret = opal_tsd_getspecific(print_tsd_key, (void**)&ptr);
    if (OPAL_SUCCESS != ret) return NULL;
    
    if (NULL == ptr) {
        ptr = (opal_hwloc_print_buffers_t*)malloc(sizeof(opal_hwloc_print_buffers_t));
        for (i=0; i < OPAL_HWLOC_PRINT_NUM_BUFS; i++) {
            ptr->buffers[i] = (char *) malloc((OPAL_HWLOC_PRINT_MAX_SIZE+1) * sizeof(char));
        }
        ptr->cntr = 0;
        ret = opal_tsd_setspecific(print_tsd_key, (void*)ptr);
    }
    
    return (opal_hwloc_print_buffers_t*) ptr;
}
Esempio n. 2
0
File: net.c Progetto: anandhis/ompi
static char*
get_hostname_buffer(void)
{
    void *buffer;
    int ret;

    ret = opal_tsd_getspecific(hostname_tsd_key, &buffer);
    if (OPAL_SUCCESS != ret) return NULL;

    if (NULL == buffer) {
        buffer = (void*) malloc((NI_MAXHOST + 1) * sizeof(char));
        ret = opal_tsd_setspecific(hostname_tsd_key, buffer);
    }

    return (char*) buffer;
}