| 868 | } |
| 869 | |
| 870 | int CStat::findCounter(const char *counter, bool alloc) |
| 871 | { |
| 872 | str_int_map::iterator it = M_genericMap.find(str_int_map::key_type(counter)); |
| 873 | if (it != M_genericMap.end()) { |
| 874 | return it->second; |
| 875 | } |
| 876 | if (!alloc) { |
| 877 | return -1; |
| 878 | } |
| 879 | int ret = M_genericMap.size() + 1; |
| 880 | M_genericMap[str_int_map::key_type(counter)] = ret; |
| 881 | |
| 882 | bool numeric = true; |
| 883 | const char *p = counter; |
| 884 | while (*p) { |
| 885 | if (!isdigit(*p)) { |
| 886 | numeric = false; |
| 887 | break; |
| 888 | } |
| 889 | p++; |
| 890 | } |
| 891 | if (numeric) { |
| 892 | char *s = new char[20]; |
| 893 | snprintf(s, 20, "GenericCounter%s", counter); |
| 894 | M_revGenericMap[ret] = s; |
| 895 | M_genericDisplay[ret] = strdup(counter); |
| 896 | } else { |
| 897 | M_revGenericMap[ret] = strdup(counter); |
| 898 | M_genericDisplay[ret] = strdup(counter); |
| 899 | } |
| 900 | |
| 901 | |
| 902 | M_genericCounters = (unsigned long long *)realloc(M_genericCounters, sizeof(unsigned long long) * GENERIC_TYPES * M_genericMap.size()); |
| 903 | if (!M_genericCounters) { |
| 904 | ERROR("Could not allocate generic counters!"); |
| 905 | } |
| 906 | M_genericCounters[(ret - 1) * GENERIC_TYPES + GENERIC_C] = 0; |
| 907 | M_genericCounters[(ret - 1) * GENERIC_TYPES + GENERIC_PD] = 0; |
| 908 | M_genericCounters[(ret - 1)* GENERIC_TYPES + GENERIC_PL] = 0; |
| 909 | |
| 910 | return ret; |
| 911 | } |
| 912 | |
| 913 | int CStat::findRtd(const char *name, bool start) |
| 914 | { |
no test coverage detected