| 126 | typedef HalfStaticArray<UCHAR, BUFFER_SMALL> CountsBuffer; |
| 127 | |
| 128 | ULONG getCounts(thread_db* tdbb, RuntimeStatistics::StatType type, CountsBuffer& buffer) |
| 129 | { |
| 130 | const Attachment* const attachment = tdbb->getAttachment(); |
| 131 | const RuntimeStatistics& stats = attachment->att_stats; |
| 132 | |
| 133 | UCHAR num_buffer[BUFFER_TINY]; |
| 134 | |
| 135 | buffer.clear(); |
| 136 | FB_SIZE_T buffer_length = 0; |
| 137 | |
| 138 | for (RuntimeStatistics::Iterator iter = stats.begin(); iter != stats.end(); ++iter) |
| 139 | { |
| 140 | const USHORT relation_id = (*iter).getRelationId(); |
| 141 | const SINT64 n = (*iter).getCounter(type); |
| 142 | |
| 143 | if (n) |
| 144 | { |
| 145 | const USHORT length = INF_convert(n, num_buffer); |
| 146 | const FB_SIZE_T new_buffer_length = buffer_length + length + sizeof(USHORT); |
| 147 | buffer.grow(new_buffer_length); |
| 148 | UCHAR* p = buffer.begin() + buffer_length; |
| 149 | STUFF_WORD(p, relation_id); |
| 150 | memcpy(p, num_buffer, length); |
| 151 | p += length; |
| 152 | buffer_length = new_buffer_length; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | return buffer.getCount(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 |
no test coverage detected