src/windows/native/sun/management/OperatingSystemImpl.c
static int
find_name(DWORD index, char *buf, DWORD size) {
    PDH_STATUS res;

    if ((res = PdhLookupPerfNameByIndex_i(NULL, index, buf, &size)) != ERROR_SUCCESS) {

        /* printf("Could not open counter %d: error=0x%08x", index, res); */
        /* if (res == PDH_CSTATUS_NO_MACHINE) { */
        /*      printf("User probably does not have sufficient privileges to use"); */
        /*      printf("performance counters. If you are running on Windows 2003"); */
        /*      printf("or Windows Vista, make sure the user is in the"); */
        /*      printf("Performance Logs user group."); */
        /* } */
        return -1;
    }

    if (size == 0) {
        /* printf("Failed to get counter name for %d: empty string", index); */
        return -1;
    }

    // windows vista does not null-terminate the string (allthough the docs says it will)
    buf[size - 1] = '\0';
    return CONFIG_SUCCESSFUL;
}
/**
 * Places the resolved counter name of the counter at the specified index in the
 * supplied buffer. There must be enough space in the buffer to hold the counter name.
 *
 * @param index   the counter index as specified in the registry.
 * @param buf     the buffer in which to place the counter name.
 * @param size      the size of the counter name buffer.
 * @param ebuf    the error message buffer.
 * @param elen    the length of the error buffer.
 * @return        CONFIG_SUCCESSFUL if successful, negative on failure.
 */
Places the resolved counter name of the counter at the specified index in the
supplied buffer. There must be enough space in the buffer to hold the counter name.

@param index   the counter index as specified in the registry.
@param buf     the buffer in which to place the counter name.
@param size      the size of the counter name buffer.
@param ebuf    the error message buffer.
@param elen    the length of the error buffer.
@return        CONFIG_SUCCESSFUL if successful, negative on failure.
Places the resolved counter name of the counter at the specified index in the supplied buffer . There must be enough space in the buffer to hold the counter name . @param index the counter index as specified in the registry . @param buf the buffer in which to place the counter name . @param size the size of the counter name buffer . @param ebuf the error message buffer . @param elen the length of the error buffer . @return CONFIG_SUCCESSFUL if successful negative on failure .
static int
find_name(DWORD index, char *buf, DWORD size) {
    PDH_STATUS res;
    if ((res = PdhLookupPerfNameByIndex_i(NULL, index, buf, &size)) != ERROR_SUCCESS) {
        return -1;
    }
    if (size == 0) {
        return -1;
    }
    buf[size - 1] = '\0';
    return CONFIG_SUCCESSFUL;
}
static int find_name ( DWORD index , char * buf , DWORD size ) { PDH_STATUS res ; if ( ( res = PdhLookupPerfNameByIndex_i ( NULL , index , buf , & size ) ) != ERROR_SUCCESS ) { return -1 ; } if ( size == 0 ) { return -1 ; } buf [ size - 1 ] = ' \0 ' ; return CONFIG_SUCCESSFUL ; }
Places the resolved counter name of the counter at the specified index in the
 supplied buffer.
Places the resolved counter name of the counter at the specified index in the supplied buffer .
/* printf("Could not open counter %d: error=0x%08x", index, res); */ /* if (res == PDH_CSTATUS_NO_MACHINE) { */ /*      printf("User probably does not have sufficient privileges to use"); */ /*      printf("performance counters. If you are running on Windows 2003"); */ /*      printf("or Windows Vista, make sure the user is in the"); */ /*      printf("Performance Logs user group."); */ /* } */ /* printf("Failed to get counter name for %d: empty string", index); */ // windows vista does not null-terminate the string (allthough the docs says it will)