core: compute the len for dns srv name

- fixes dns srv for cache, reported by Rob Eijgenraam, FS#426

(cherry picked from commit b834cde74f8a4b41ec24ceb8332adff8bb3922bb)
(cherry picked from commit 70f1b7479f80ca4f5e3a45fcf772785c110d0b57)
mtree: replace tree structure even there are no records in db table

- reload didn't replaced old tree if no records in db table
- reported by Juha Heinanen

(cherry picked from commit c36f326d3c7372b149592d438df75f3d7b0a0233)
(cherry picked from commit 47a00936695c46176c3c047e0ab141b4127d08dc)
db_mysql: proper handling of mysql_next_result(...) return code

- it indicates the presence of another result if return is 0
- reported by  Maxim (simax), FS#434

(cherry picked from commit 37f0964278e925d5530563b38c82a57de1f7fa59)
(cherry picked from commit af4f84b84ca7601bd8124fe2e82d0718c7975313)
rls: Fix memory leak with duplicate entries in lists

- When duplicate detection is requested, free the string and container
- When duplicate detection is not requested, insert the duplicate anyway

(cherry picked from commit 5cd3bd3a1bbcc9edffe31c0b1fdf11da43023b2c)
parser/sdp: assign stream var only if session is not null

(cherry picked from commit 1cefc0c5f83eb4b7b6ffefc6ab383d7aae6de07f)
(cherry picked from commit ad5235229f59ba5d1f4216e144291e110fee0211)
dialog: add wait-for-ack callback before response unref

- in case of a sipral for ending in a negative response from initial
  state, ack to second iteration can unref prematurely the dialog
- reported by Pawel Sternal, FS#427

(cherry picked from commit d81fd1bf067b78b55ad348db2531c4ba9b10dddb)
(cherry picked from commit 642428cf8be1c7355f91b14276e888ec505cd69a)
srdb1: fix memory leak in db-id

- When getting an existing connection from the pool, free the newly
  created db-id as the pool connection already has a reference to the
  existing one.  Fixes FS#436
(cherry picked from commit 69de17d3bb1d032f9a41752362194d718336e20d)

(cherry picked from commit 94ebfb5d5973ed59de84ca0e0c87052b4c80f9de)
auth: enhanced log message when method param fails to be retrieved

(cherry picked from commit 35329870fe22115fd24a396b743e4814278ce46a)
(cherry picked from commit 3997dcccf36579442cb92222fe0868accd64b537)
mem/f_malloc: check returned pointer for bitmask index

- if null, reset slot and search on bigger chunks slots

(cherry picked from commit 892a24f7256e60e2a0116655e0052c284479b7d2)
(cherry picked from commit 2cfb00b4a24f24cd9462305f4518797706b8f6f1)
mem/f_malloc: free old pointer if allocation in realloc fails

(cherry picked from commit 41a37b570758445d723d4d78b9786f8e6cb5722c)
(cherry picked from commit ce46f5482f56378beba16c68d1e5af5e5d593008)
mem/q_malloc: free old pointer if allocation in realloc fails

(cherry picked from commit 8c2888fcd33bee45cb4654222da619e70ed44ecc)
(cherry picked from commit 3457dc459acd7eba96a0cb77e7d50cfc349c303e)
dialog: if sending BYE fails at timeout, unref dialog

- destroy dialog structures

(cherry picked from commit e39a90e11bfed2b4445c37db1532488aa9e3e725)
(cherry picked from commit 12a0a927aa3ad6dfbb18ab3fcf1927bf51098925)
core: free previous allocated variable if no more pkg to build rve struct

- cleaner shut down if not enough memory at startup

(cherry picked from commit ace56c6bd2221920b965185c1c9a5997cd3f2768)
(cherry picked from commit c5c1002be8c4f3e24d1b79b77856db2879b97c72)
db_flatstore: free result before returning null on no more pkg

- partial allocation when doing an incomplete new connection

(cherry picked from commit 74743d6ef3bf74c1226ba5a1b6bebfbe19b06b93)
(cherry picked from commit 386ef2f61d18966ceb70916869389f2690e0a6ef)
rls: proper header define guard and check of null returned value

(cherry picked from commit 4f2da3e025fa281f88e80bb841a51d6546219ae8)
(cherry picked from commit 3c7e14f849884d5d145a7ab9c942acbbc9c5d282)
kamcmd: proper size for memset, based on malloc

(cherry picked from commit 7134959725011baa504a027c4561e0054dd907ae)
(cherry picked from commit a768ffa5a083bbddc35db59b2686046c000c0482)
topoh: match on all ports if none is in the uri for checking self

- forcing default 5060 can fail for multi-listen case and tls

(cherry picked from commit 1d90f4de94dfc887cc6129624fd5e6ad989abd37)
(cherry picked from commit fdea08a522ed6d1e30b6b8eab0e74bc47078d57d)
core: use port 5061 for checking self when uri has transport tls

- 5060 was used, failing to match myself condition

(cherry picked from commit 2e55d7bd218c9f954da7d289ec1be090bb4d88b0)
(cherry picked from commit a008e0f7d0920d061892819a121d1f07ba4b2a70)
core: print number of parameters used for searching cfg function

(cherry picked from commit a313a8d33afdee6c7eb70cd57161aef8e70c5bcf)
(cherry picked from commit 93fb970b87216ea5f63b077f02bbe1c085ddc45c)
modules/siputils:  generate error message if parsing of is_gruu() uri fails

(cherry picked from commit 365a60772de9c1d2f19ecf52b12f6d75b348e996)
(cherry picked from commit 7453f5e3b10b4a257eb2e1e1650bfabc5f381ec5)