* backed by an array.
*
* @note Maximum object size is 2^16 bytes, see ::pack_objlen_t
+ * @TODO If some mistake happens somewhere, the access may end up in an infinite loop.
+ * (equality comparison on pointers)
*
* # Example usage:
*
return pack_obj_val(it) + pack_obj_len(it);
}
+/** Return pointer to the last packed object. */
+static inline uint8_t *pack_last(pack_t pack)
+{
+ if (pack.len == 0) {
+ return NULL;
+ }
+ uint8_t *it = pack_head(pack);
+ uint8_t *tail = pack_tail(pack);
+ while (true) {
+ uint8_t *next = pack_obj_next(it);
+ if (next == tail) {
+ return it;
+ }
+ it = next;
+ }
+}
+
/** Push object to the end of the pack
* @return 0 on success, negative number on failure
*/
knot_rrset_init(&rr, qname, KNOT_RRTYPE_PTR, KNOT_CLASS_IN);
/* Append address records from hints */
- uint8_t *addr = pack_head(*addr_set);
+ uint8_t *addr = pack_last(*addr_set);
if (addr != NULL) {
size_t len = pack_obj_len(addr);
void *addr_val = pack_obj_val(addr);
continue;
}
char *name_tok = strtok_r(NULL, " \t\n", &saveptr);
+ bool canonical_name = true;
while (name_tok != NULL) {
- add_reverse_pair(&data->reverse_hints, name_tok, tok);
+ if (canonical_name) {
+ add_reverse_pair(&data->reverse_hints, name_tok, tok);
+ canonical_name = false;
+ }
if (add_pair(&data->hints, name_tok, tok) == 0) {
count += 1;
}