Changeset dc95342 in mainline for uspace/srv/net/dnsres/dns_msg.c
- Timestamp:
- 2013-04-22T06:45:49Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 31e9fe0
- Parents:
- 7262f89
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/net/dnsres/dns_msg.c
r7262f89 rdc95342 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 489 489 dns_question_t *q = list_get_instance(link, dns_question_t, msg); 490 490 rc = dns_question_encode(q, data + di, size - di, &q_size); 491 assert(rc == EOK); 491 if (rc != EOK) { 492 assert(rc == ENOMEM || rc == EINVAL); 493 free(data); 494 return rc; 495 } 492 496 493 497 di += q_size; … … 578 582 return EOK; 579 583 error: 580 /* XXX Destroy message */584 dns_message_destroy(msg); 581 585 return rc; 586 } 587 588 static void dns_question_destroy(dns_question_t *question) 589 { 590 free(question->qname); 591 free(question); 592 } 593 594 static void dns_rr_destroy(dns_rr_t *rr) 595 { 596 free(rr->name); 597 free(rr->rdata); 598 free(rr); 599 } 600 601 void dns_message_destroy(dns_message_t *msg) 602 { 603 link_t *link; 604 dns_question_t *question; 605 dns_rr_t *rr; 606 607 while (!list_empty(&msg->question)) { 608 link = list_first(&msg->question); 609 question = list_get_instance(link, dns_question_t, msg); 610 list_remove(&question->msg); 611 dns_question_destroy(question); 612 } 613 614 while (!list_empty(&msg->answer)) { 615 link = list_first(&msg->answer); 616 rr = list_get_instance(link, dns_rr_t, msg); 617 list_remove(&rr->msg); 618 dns_rr_destroy(rr); 619 } 620 621 while (!list_empty(&msg->authority)) { 622 link = list_first(&msg->authority); 623 rr = list_get_instance(link, dns_rr_t, msg); 624 list_remove(&rr->msg); 625 dns_rr_destroy(rr); 626 } 627 628 while (!list_empty(&msg->additional)) { 629 link = list_first(&msg->additional); 630 rr = list_get_instance(link, dns_rr_t, msg); 631 list_remove(&rr->msg); 632 dns_rr_destroy(rr); 633 } 634 635 free(msg); 582 636 } 583 637
Note:
See TracChangeset
for help on using the changeset viewer.