<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Hi,<br>
    <br>
    While testing my application, which uses getdns 0.9.0, I found two
    small memory leaks related to getdns_context_get_api_information(),
    but probably I'm missing something...<br>
    <br>
    I destroy the returned dict from
    getdns_context_get_api_information(), but according to valgrind
    there are two leaks. The first (context.c:2948) refers to the dns
    transport list, the second to the namespaces list. Apparently these
    are not freed as part of the getdns_dict_destroy().<br>
    <br>
    Am I forgetting to destroy something?<br>
    <br>
    <tt>        res = getdns_context_create(&ctxt, 0);</tt><tt><br>
    </tt><tt>        if (res == GETDNS_RETURN_GOOD)</tt><tt><br>
    </tt><tt>        {</tt><tt><br>
    </tt><tt>            dict = <b>getdns_context_get_api_information</b>(ctxt);</tt><tt><br>
    </tt><tt>            if (dict != NULL)</tt><tt><br>
                  {<br>
    </tt><tt>                if ((res = <b>getdns_dict_get_bindata</b>(dict,
      "/version_string",</tt><tt><br>
    </tt><tt>                                               
      &version)) == GETDNS_RETURN_GOOD))</tt><tt><br>
    </tt><tt>                {</tt><tt><br>
    </tt><tt>                    trace_mod(TRACE_INFO,</tt><tt><br>
    </tt><tt>                              "Using getdns library version
      %.*s",</tt><tt><br>
    </tt><tt>                               version->size,
      version->data);</tt><tt><br>
                      }<br>
    </tt><tt>                <b>getdns_dict_destroy</b>(dict);</tt><tt><br>
    </tt><tt>                dict = NULL;</tt><tt><br>
    </tt><tt>            }</tt><tt><br>
    </tt><tt>            else</tt><tt><br>
    </tt><tt>            {</tt><tt><br>
    </tt><tt>                trace_mod(BF_TRACE_ERROR,</tt><tt><br>
    </tt><tt>                          "Failed to initialise getdns
      library: %s (%d)",</tt><tt><br>
    </tt><tt>                          getdns_get_errorstr_by_id(res),
      res);</tt><tt><br>
    </tt><tt>                retval = FAILURE;</tt><tt><br>
    </tt><tt>            }</tt><tt><br>
    </tt><tt><br>
    </tt><tt>            /* Cleanup */</tt><tt><br>
    </tt><tt>            <b>getdns_context_destroy</b>(ctxt);</tt><tt><br>
    </tt><tt>            ctxt = NULL;</tt><tt><br>
    </tt><tt>        }</tt><br>
    <br>
    <blockquote type="cite">==11484== 216 (56 direct, 160 indirect)
      bytes in 1 blocks are definitely lost in loss record 637 of 686<br>
      ==11484==    at 0x4A08455: malloc (vg_replace_malloc.c:299)<br>
      ==11484==    by 0x224B6F86:
      getdns_list_create_with_extended_memory_functions (list.c:380)<br>
      ==11484==    by 0x224C5F15: _get_context_settings (context.c:2948)<br>
      ==11484==    by 0x224C5F15: <b>getdns_context_get_api_information
      </b>(context.c:2986)<br>
      ==11484==    by 0x22191724: mf_am_init (enum_init.c:136)<br>
      ==11484==    by 0x4366F0: mf_am_process_init (mf_am.c:837)<br>
      ==11484==    by 0x43B23A: mf_core_init (mf_core.c:487)<br>
      ==11484==    by 0x40FB31: main (mf_main.c:422)<br>
      ==11484== <br>
      ==11484== 216 (56 direct, 160 indirect) bytes in 1 blocks are
      definitely lost in loss record 638 of 686<br>
      ==11484==    at 0x4A08455: malloc (vg_replace_malloc.c:299)<br>
      ==11484==    by 0x224B6F86:
      getdns_list_create_with_extended_memory_functions (list.c:380)<br>
      ==11484==    by 0x224C5DE2: _get_context_settings (context.c:2960)<br>
      ==11484==    by 0x224C5DE2: <b>getdns_context_get_api_information</b>
      (context.c:2986)<br>
      ==11484==    by 0x22191724: mf_am_init (enum_init.c:136)<br>
      ==11484==    by 0x4366F0: mf_am_process_init (mf_am.c:837)<br>
      ==11484==    by 0x43B23A: mf_core_init (mf_core.c:487)<br>
      ==11484==    by 0x40FB31: main (mf_main.c:422)<br>
    </blockquote>
    <br>
    Thanks,<br>
    Robert<br>
  </body>
</html>