src/components/sde/sde.c
/** This function finds the handle associated with a created counter, or a recorder,
  given the library handle and the event name.
  @param[in] handle -- (void *) pointer to sde structure for an individual 
  library
  @param[in] event_name -- name of the event 
  */
This function finds the handle associated with a created counter, or a recorder,
given the library handle and the event name.
This function finds the handle associated with a created counter or a recorder given the library handle and the event name .
void 
__attribute__((visibility("default")))
*papi_sde_get_counter_handle( void *handle, const char *event_name)
{   
    sde_counter_t *counter_handle;
    papisde_library_desc_t *lib_handle;
    char *full_event_name;
    lib_handle = (papisde_library_desc_t *) handle;
    if( (NULL == lib_handle) || (NULL == lib_handle->libraryName) ){
        PAPIERROR("papi_sde_get_counter_handle(): 'handle' is clobbered.\n");
        return NULL;
    }
    size_t str_len = strlen(lib_handle->libraryName)+strlen(event_name)+2+1; 
    full_event_name = malloc(str_len*sizeof(char));
    snprintf(full_event_name, str_len, "%s::%s", lib_handle->libraryName, event_name);
    papi_sde_lock();
    counter_handle = ht_lookup_by_name(lib_handle->lib_counters, full_event_name);
    papi_sde_unlock();
    free(full_event_name);
    return counter_handle;
}
void __attribute__ ( ( visibility ( " " ) ) ) * papi_sde_get_counter_handle ( void * handle , const char * event_name ) { sde_counter_t * counter_handle ; papisde_library_desc_t * lib_handle ; char * full_event_name ; lib_handle = ( papisde_library_desc_t * ) handle ; if ( ( NULL == lib_handle ) || ( NULL == lib_handle -> libraryName ) ) { PAPIERROR ( " \n " ) ; return NULL ; } size_t str_len = strlen ( lib_handle -> libraryName ) + strlen ( event_name ) + 2 + 1 ; full_event_name = malloc ( str_len * sizeof ( char ) ) ; snprintf ( full_event_name , str_len , " " , lib_handle -> libraryName , event_name ) ; papi_sde_lock ( ) ; counter_handle = ht_lookup_by_name ( lib_handle -> lib_counters , full_event_name ) ; papi_sde_unlock ( ) ; free ( full_event_name ) ; return counter_handle ; }
This function finds the handle associated with a created counter, or a recorder,
given the library handle and the event name.
This function finds the handle associated with a created counter or a recorder given the library handle and the event name .
// +2 for "::" and +1 for '\0' // After this point we will be accessing shared data structures, so we need to acquire a lock.