| 1167 | } |
| 1168 | |
| 1169 | PB_API pb_Field** pb_sortfield(pb_Type* t) { |
| 1170 | if (!t->field_sort && t->field_count) { |
| 1171 | int index = 0; |
| 1172 | unsigned int i = 0; |
| 1173 | const pb_Field* f = NULL; |
| 1174 | pb_Field** list = (pb_Field**)malloc(sizeof(pb_Field*) * t->field_count); |
| 1175 | |
| 1176 | assert(list); |
| 1177 | while (pb_nextfield(t, &f)) { |
| 1178 | list[index++] = (pb_Field*)f; |
| 1179 | } |
| 1180 | |
| 1181 | qsort(list, index, sizeof(pb_Field*), comp_field); |
| 1182 | for (i = 0; i < t->field_count; i++) { |
| 1183 | list[i]->sort_index = i + 1; |
| 1184 | } |
| 1185 | t->field_sort = list; |
| 1186 | } |
| 1187 | |
| 1188 | return t->field_sort; |
| 1189 | } |
| 1190 | |
| 1191 | PB_API const pb_Name *pb_oneofname(const pb_Type *t, int idx) { |
| 1192 | pb_OneofEntry *oe = NULL; |
no test coverage detected