Changeset 184


Ignore:
Timestamp:
03/20/10 13:50:44 (15 years ago)
Author:
tim
Message:

redesigned memory management to allow for multiple references to talloc-ed objects

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/regfi.h

    r182 r184  
    7878#include "lru_cache.h"
    7979
     80
     81/******************************************************************************/
     82/* Constants for use while interacting with the library                       */
    8083/******************************************************************************/
    8184
     
    8487#define REGFI_LOG_WARN  0x0004
    8588#define REGFI_LOG_ERROR 0x0010
    86 
    87 /* For internal use */
    88 pthread_key_t REGFI_LOG_KEY;
    8989
    9090typedef uint8_t REGFI_ENCODING;
     
    119119
    120120
     121
     122/******************************************************************************/
     123/* Various resource limits and related constants                              */
     124/******************************************************************************/
     125
     126/* Flags determining whether or not to cache various record types internally */
     127#define REGFI_CACHE_SK             0
     128
    121129/* This maximum depth is described here:
    122130 * http://msdn.microsoft.com/en-us/library/ms724872%28VS.85%29.aspx
     
    132140#define REGFI_MAX_SUBKEY_DEPTH     255
    133141
     142
     143/******************************************************************************/
     144/* Symbols for internal use                                                   */
     145/******************************************************************************/
     146
     147/* Global thread-local storage key */
     148pthread_key_t REGFI_LOG_KEY;
    134149
    135150/* Header sizes and magic number lengths for various records */
     
    236251#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
    237252
     253
     254
     255/******************************************************************************/
     256/* Structures                                                                 */
     257/******************************************************************************/
     258
    238259typedef struct _regfi_nttime
    239260{
     
    825846 *
    826847 * @return A reference to a newly allocated REGFI_FILE structure, if successful;
    827  *         NULL on error.
     848 *         NULL on error.  Use regfi_free to free the returned REGFI_FILE.
    828849 *
    829850 * @ingroup regfiBase
     
    840861 *
    841862 * @return A reference to a newly allocated REGFI_FILE structure, if successful;
    842  *         NULL on error.
     863 *         NULL on error.  Use regfi_free to free the returned REGFI_FILE.
    843864 *
    844865 * @ingroup regfiBase
     
    909930/* Dispose of previously parsed records */
    910931
    911 /** Frees a key structure previously returned by one of the API functions
    912  *
    913  * XXX: finish documenting
     932/** Frees a record previously returned by one of the API functions.
     933 *
     934 * Can be used to free REGFI_NK_REC, REGFI_VK_REC, REGFI_SK_REC, REGFI_DATA, and
     935 * REGFI_CLASSNAME records.
     936 *
     937 * @note The "const" in the data type is a bit misleading and is there just for
     938 * convenience.  Since records returned previously must not be modified by users
     939 * of the API due to internal caching, these are returned as const, so this
     940 * function is const to make passing back in easy.
    914941 *
    915942 * @ingroup regfiBase
    916943 */
    917 void                  regfi_free_key(REGFI_NK_REC* nk);
    918 
    919 
    920 /** Frees a value structure previously returned by one of the API functions
    921  *
    922  * XXX: finish documenting
    923  *
    924  * @ingroup regfiBase
    925  */
    926 void                  regfi_free_value(REGFI_VK_REC* vk);
    927 
     944void regfi_free_record(const void* record);
    928945
    929946
     
    10381055 * @ingroup regfiIteratorLayer
    10391056 */
    1040 const REGFI_NK_REC*   regfi_iterator_cur_key(REGFI_ITERATOR* i);
     1057const REGFI_NK_REC* regfi_iterator_cur_key(REGFI_ITERATOR* i);
    10411058
    10421059
     
    10491066 * @ingroup regfiIteratorLayer
    10501067 */
    1051 const REGFI_SK_REC*   regfi_iterator_cur_sk(REGFI_ITERATOR* i);
     1068const REGFI_SK_REC* regfi_iterator_cur_sk(REGFI_ITERATOR* i);
    10521069
    10531070
     
    10601077 *         subkey, or NULL on failure.  Failure may be due to a lack of any
    10611078 *         subkeys or other errors.  Newly allocated keys must be freed with
    1062  *         regfi_free_key.
    1063  *
    1064  * @ingroup regfiIteratorLayer
    1065  */
    1066 REGFI_NK_REC*        regfi_iterator_first_subkey(REGFI_ITERATOR* i);
     1079 *         regfi_free_record.
     1080 *
     1081 * @ingroup regfiIteratorLayer
     1082 */
     1083const REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i);
    10671084
    10681085
     
    10731090 * @return A newly allocated key structure for the currently referenced subkey,
    10741091 *         or NULL on failure.  Newly allocated keys must be freed with
    1075  *         regfi_free_key.
    1076  *
    1077  * @ingroup regfiIteratorLayer
    1078  */
    1079 REGFI_NK_REC*        regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
     1092 *         regfi_free_record.
     1093 *
     1094 * @ingroup regfiIteratorLayer
     1095 */
     1096const REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i);
    10801097
    10811098
     
    10861103 *
    10871104 * @return A newly allocated key structure for the next subkey or NULL on
    1088  *         failure.  Newly allocated keys must be freed with regfi_free_key.
    1089  *
    1090  * @ingroup regfiIteratorLayer
    1091  */
    1092 REGFI_NK_REC*        regfi_iterator_next_subkey(REGFI_ITERATOR* i);
     1105 *         failure.  Newly allocated keys must be freed with regfi_free_record.
     1106 *
     1107 * @ingroup regfiIteratorLayer
     1108 */
     1109const REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i);
    10931110
    10941111
     
    11041121 * @ingroup regfiIteratorLayer
    11051122 */
    1106 bool                  regfi_iterator_find_subkey(REGFI_ITERATOR* i,
    1107                                                  const char* subkey_name);
     1123bool regfi_iterator_find_subkey(REGFI_ITERATOR* i, const char* subkey_name);
     1124
    11081125
    11091126/** Sets the internal value index to the first value referenced by the current
     
    11151132 *          value, or NULL on failure.  Failure may be due to a lack of any
    11161133 *          values or other errors.  Newly allocated keys must be freed with
    1117  *          regfi_free_value.
    1118  *
    1119  * @ingroup regfiIteratorLayer
    1120  */
    1121 REGFI_VK_REC*        regfi_iterator_first_value(REGFI_ITERATOR* i);
     1134 *          regfi_free_record.
     1135 *
     1136 * @ingroup regfiIteratorLayer
     1137 */
     1138const REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i);
    11221139
    11231140
     
    11281145 * @return A newly allocated value structure for the currently referenced value,
    11291146 *         or NULL on failure.  Newly allocated values must be freed with
    1130  *         regfi_free_value.
    1131  *
    1132  * @ingroup regfiIteratorLayer
    1133  */
    1134 REGFI_VK_REC*        regfi_iterator_cur_value(REGFI_ITERATOR* i);
     1147 *         regfi_free_record.
     1148 *
     1149 * @ingroup regfiIteratorLayer
     1150 */
     1151const REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i);
    11351152
    11361153
     
    11411158 *
    11421159 * @return  A newly allocated key structure for the next value or NULL on
    1143  *          failure.  Newly allocated keys must be freed with regfi_free_value.
    1144  *
    1145  * @ingroup regfiIteratorLayer
    1146  */
    1147 REGFI_VK_REC*        regfi_iterator_next_value(REGFI_ITERATOR* i);
     1160 *          failure.  Newly allocated keys must be freed with regfi_free_record.
     1161 *
     1162 * @ingroup regfiIteratorLayer
     1163 */
     1164const REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i);
    11481165
    11491166
     
    11681185 *
    11691186 * @return Returns a newly allocated classname structure, or NULL on failure.
    1170  *         Classname structures must be freed with regfi_free_classname.
    1171  *
    1172  * @ingroup regfiIteratorLayer
    1173  */
    1174 REGFI_CLASSNAME*      regfi_iterator_fetch_classname(REGFI_ITERATOR* i,
    1175                                                      const REGFI_NK_REC* key);
     1187 *         Classname structures must be freed with regfi_free_record.
     1188 *
     1189 * @ingroup regfiIteratorLayer
     1190 */
     1191const REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i,
     1192                                                      const REGFI_NK_REC* key);
    11761193
    11771194
     
    11821199 *
    11831200 * @return Returns a newly allocated data structure, or NULL on failure.
    1184  *         Data structures must be freed with regfi_free_data.
    1185  *
    1186  * @ingroup regfiIteratorLayer
    1187  */
    1188 REGFI_DATA*           regfi_iterator_fetch_data(REGFI_ITERATOR* i,
    1189                                                 const REGFI_VK_REC* value);
     1201 *         Data structures must be freed with regfi_free_record.
     1202 *
     1203 * @ingroup regfiIteratorLayer
     1204 */
     1205const REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i,
     1206                                            const REGFI_VK_REC* value);
    11901207
    11911208
     
    12761293                                           uint32_t type, REGFI_DATA* data);
    12771294
    1278 
    1279 /** Frees the memory associated with a REGFI_CLASSNAME data structure.
    1280  *
    1281  * XXX: finish documenting
    1282  *
    1283  * @ingroup regfiGlueLayer
    1284  */
    1285 void                  regfi_free_classname(REGFI_CLASSNAME* classname);
    1286 
    1287 
    1288 /** Frees the memory associated with a REGFI_DATA data structure.
    1289  *
    1290  * XXX: finish documenting
    1291  *
    1292  * @ingroup regfiGlueLayer
    1293  */
    1294 void                  regfi_free_data(REGFI_DATA* data);
    12951295
    12961296
     
    14341434REGFI_NK_REC*         regfi_rootkey(REGFI_FILE* file,
    14351435                                    REGFI_ENCODING output_encoding);
    1436 void                  regfi_subkeylist_free(REGFI_SUBKEY_LIST* list);
    14371436
    14381437off_t                 regfi_raw_seek(REGFI_RAW_FILE* self,
  • trunk/lib/lru_cache.c

    r169 r184  
    119119  if(max_keys == 0)
    120120    ret_val->num_buckets = 1024;
     121  else if(max_keys == 1)
     122    ret_val->num_buckets = 1;   
    121123  else
    122124  {
     
    125127      ret_val->num_buckets = 1;
    126128  }
    127 
     129 
    128130  ret_val->table = talloc_array(ret_val,
    129131                                lru_cache_element*, ret_val->num_buckets);
     
    177179     */
    178180    if(ht->talloc_data)
    179       talloc_free(e->data);
     181      talloc_unlink(e, e->data);
    180182
    181183    if(e->newer == NULL)
     
    224226
    225227      if(ht->talloc_data)
    226         talloc_free(e->data);
     228        talloc_unlink(e, e->data);
    227229
    228230      tmp_index = talloc_realloc_size(e, e->index, index_len);
     
    261263  e->data = data;
    262264  if(ht->talloc_data)
    263     talloc_steal(e, e->data);
     265    talloc_reference(e, e->data);
    264266
    265267  /* Finally, let's insert the element to the newest position in the LRU list.*/
  • trunk/lib/regfi.c

    r182 r184  
    947947 
    948948  for(i=0; i < num_lists; i++)
    949     regfi_subkeylist_free(lists[i]);
     949    talloc_free(lists[i]);
    950950  free(lists);
    951951
     
    11851185    if(vk->valuename == NULL)
    11861186    {
    1187       regfi_free_value(vk);
     1187      talloc_free(vk);
    11881188      return;
    11891189    }
     
    12791279    if(nk->keyname == NULL)
    12801280    {
    1281       regfi_free_key(nk);
     1281      talloc_free(nk);
    12821282      return;
    12831283    }
     
    13331333      if(strict)
    13341334      {
    1335         regfi_free_key(nk);
     1335        talloc_free(nk);
    13361336        return NULL;
    13371337      }
     
    13501350        if(strict)
    13511351        {
    1352           regfi_free_key(nk);
     1352          talloc_free(nk);
    13531353          return NULL;
    13541354        }
     
    13671367      if(strict)
    13681368      {
    1369         regfi_free_key(nk);
     1369        talloc_free(nk);
    13701370        return NULL;
    13711371      }
     
    14001400  void* failure_ptr = NULL;
    14011401 
     1402  max_size = regfi_calc_maxsize(file, offset);
     1403  if(max_size < 0)
     1404    return NULL;
     1405
     1406  if(file->sk_cache == NULL)
     1407    return regfi_parse_sk(file, offset, max_size, strict);
     1408
    14021409  if(!regfi_lock(file, file->sk_lock, "regfi_load_sk"))
    14031410    return NULL;
     
    14121419  if(ret_val == NULL)
    14131420  {
    1414     max_size = regfi_calc_maxsize(file, offset);
    1415     if(max_size < 0)
    1416       return NULL;
    1417 
    14181421    ret_val = regfi_parse_sk(file, offset, max_size, strict);
    14191422    if(ret_val == NULL)
     
    14241427      *(uint32_t*)failure_ptr = REGFI_OFFSET_NONE;
    14251428      lru_cache_update(file->sk_cache, &offset, 4, failure_ptr);
     1429
     1430      /* Let the cache be the only owner of this */
     1431      talloc_unlink(NULL, failure_ptr);
    14261432      return NULL;
    14271433    }
    1428 
    1429     lru_cache_update(file->sk_cache, &offset, 4, ret_val);
    14301434  }
    14311435
    14321436  if(!regfi_unlock(file, file->sk_lock, "regfi_load_sk"))
    1433     return NULL;
     1437  {
     1438    talloc_unlink(NULL, ret_val);
     1439    return NULL;
     1440  }
    14341441
    14351442  return ret_val;
     
    15971604  cache_secret = 0x15DEAD05^time(NULL)^(getpid()<<16);
    15981605
    1599   /* Cache an unlimited number of SK records.  Typically there are very few. */
    1600   rb->sk_cache = lru_cache_create_ctx(rb, 0, cache_secret, true);
     1606  if(REGFI_CACHE_SK)
     1607    rb->sk_cache = lru_cache_create_ctx(rb, 64, cache_secret, true);
     1608  else
     1609    rb->sk_cache = NULL;
    16011610
    16021611  /* success */
     
    16781687/******************************************************************************
    16791688 *****************************************************************************/
    1680 void regfi_free_key(REGFI_NK_REC* nk)
    1681 {
    1682   regfi_subkeylist_free(nk->subkeys);
    1683   talloc_free(nk);
    1684 }
    1685 
    1686 
    1687 /******************************************************************************
    1688  *****************************************************************************/
    1689 void regfi_free_value(REGFI_VK_REC* vk)
    1690 {
    1691   talloc_free(vk);
    1692 }
    1693 
    1694 
    1695 /******************************************************************************
    1696  *****************************************************************************/
    1697 void regfi_subkeylist_free(REGFI_SUBKEY_LIST* list)
    1698 {
    1699   if(list != NULL)
    1700   {
    1701     talloc_free(list);
    1702   }
    1703 }
     1689void regfi_free_record(const void* record)
     1690{
     1691  talloc_unlink(NULL, (void*)record);
     1692}
     1693
    17041694
    17051695
     
    17311721  }
    17321722  ret_val->cur_key = root;
    1733   talloc_steal(ret_val, root);
     1723  talloc_reference(ret_val, root);
    17341724
    17351725  ret_val->key_positions = void_stack_new(REGFI_MAX_DEPTH);
     
    17831773  {
    17841774    talloc_free(pos);
    1785     regfi_free_key(subkey);
     1775    talloc_unlink(NULL, subkey);
    17861776    return false;
    17871777  }
    1788   talloc_steal(i, subkey);
     1778  talloc_reference(i, subkey);
    17891779
    17901780  i->cur_key = subkey;
     
    18061796    return false;
    18071797
    1808   regfi_free_key(i->cur_key);
     1798  talloc_unlink(i, i->cur_key);
    18091799  i->cur_key = pos->nk;
    18101800  i->cur_subkey = pos->cur_subkey;
     
    18471837    else
    18481838    {
    1849       regfi_free_key(subkey);
     1839      talloc_unlink(NULL, subkey);
    18501840      subkey = (REGFI_NK_REC*)regfi_iterator_next_subkey(i);
    18511841    }
     
    18581848  }
    18591849
    1860   regfi_free_key(subkey);
     1850  talloc_unlink(NULL, subkey);
    18611851  return true;
    18621852}
     
    19091899/******************************************************************************
    19101900 *****************************************************************************/
    1911 REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i)
     1901const REGFI_NK_REC* regfi_iterator_first_subkey(REGFI_ITERATOR* i)
    19121902{
    19131903  i->cur_subkey = 0;
     
    19181908/******************************************************************************
    19191909 *****************************************************************************/
    1920 REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i)
     1910const REGFI_NK_REC* regfi_iterator_cur_subkey(REGFI_ITERATOR* i)
    19211911{
    19221912  uint32_t nk_offset;
     
    19291919  nk_offset = i->cur_key->subkeys->elements[i->cur_subkey].offset;
    19301920
    1931   return regfi_load_key(i->f, nk_offset+REGFI_REGF_SIZE, i->string_encoding,
    1932                         true);
     1921  return regfi_load_key(i->f, nk_offset+REGFI_REGF_SIZE,
     1922                        i->string_encoding, true);
    19331923}
    19341924
     
    19371927 *****************************************************************************/
    19381928/* XXX: some way of indicating reason for failure should be added. */
    1939 REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i)
    1940 {
    1941   REGFI_NK_REC* subkey;
     1929const REGFI_NK_REC* regfi_iterator_next_subkey(REGFI_ITERATOR* i)
     1930{
     1931  const REGFI_NK_REC* subkey;
    19421932
    19431933  i->cur_subkey++;
     
    19551945bool regfi_iterator_find_value(REGFI_ITERATOR* i, const char* value_name)
    19561946{
    1957   REGFI_VK_REC* cur;
     1947  const REGFI_VK_REC* cur;
    19581948  bool found = false;
    19591949  uint32_t old_value = i->cur_value;
     
    19731963    else
    19741964    {
    1975       regfi_free_value(cur);
     1965      regfi_free_record(cur);
    19761966      cur = regfi_iterator_next_value(i);
    19771967    }
     
    19841974  }
    19851975
    1986   regfi_free_value(cur);
     1976  regfi_free_record(cur);
    19871977  return true;
    19881978}
     
    19911981/******************************************************************************
    19921982 *****************************************************************************/
    1993 REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i)
     1983const REGFI_VK_REC* regfi_iterator_first_value(REGFI_ITERATOR* i)
    19941984{
    19951985  i->cur_value = 0;
     
    20001990/******************************************************************************
    20011991 *****************************************************************************/
    2002 REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i)
     1992const REGFI_VK_REC* regfi_iterator_cur_value(REGFI_ITERATOR* i)
    20031993{
    20041994  REGFI_VK_REC* ret_val = NULL;
     
    20212011/******************************************************************************
    20222012 *****************************************************************************/
    2023 REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i)
    2024 {
    2025   REGFI_VK_REC* ret_val;
     2013const REGFI_VK_REC* regfi_iterator_next_value(REGFI_ITERATOR* i)
     2014{
     2015  const REGFI_VK_REC* ret_val;
    20262016
    20272017  i->cur_value++;
     
    20362026/******************************************************************************
    20372027 *****************************************************************************/
    2038 REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i,
    2039                                                 const REGFI_NK_REC* key)
     2028const REGFI_CLASSNAME* regfi_iterator_fetch_classname(REGFI_ITERATOR* i,
     2029                                                      const REGFI_NK_REC* key)
    20402030{
    20412031  REGFI_CLASSNAME* ret_val;
     
    21002090/******************************************************************************
    21012091 *****************************************************************************/
    2102 REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i,
    2103                                       const REGFI_VK_REC* value)
     2092const REGFI_DATA* regfi_iterator_fetch_data(REGFI_ITERATOR* i,
     2093                                            const REGFI_VK_REC* value)
    21042094{
    21052095  REGFI_DATA* ret_val = NULL;
     
    21402130 
    21412131  return ret_val;
    2142 }
    2143 
    2144 
    2145 /******************************************************************************
    2146  *****************************************************************************/
    2147 void regfi_free_classname(REGFI_CLASSNAME* classname)
    2148 {
    2149   talloc_free(classname);
    2150 }
    2151 
    2152 /******************************************************************************
    2153  *****************************************************************************/
    2154 void regfi_free_data(REGFI_DATA* data)
    2155 {
    2156   talloc_free(data);
    21572132}
    21582133
  • trunk/src/common.c

    r182 r184  
    163163 * value, and a non-NULL (*error_msg).
    164164 */
    165 static char* data_to_ascii(REGFI_DATA* data, char** error_msg)
     165static char* data_to_ascii(const REGFI_DATA* data, char** error_msg)
    166166{
    167167  char* ret_val;
  • trunk/src/reglookup-recover.c

    r182 r184  
    291291        {
    292292          /* XXX: Need to add a warning here */
    293           regfi_free_key(cur_ancestor);
     293          regfi_free_record(cur_ancestor);
    294294          void_stack_free(path_stack);
    295295          return NULL;
     
    303303        ret_val_size += path_element->len + 1;
    304304
    305         regfi_free_key(cur_ancestor);
     305        regfi_free_record(cur_ancestor);
    306306      }
    307307    }
     
    631631
    632632 fail:
    633   regfi_free_key(key);
     633  regfi_free_record(key);
    634634  return error_code;
    635635}
  • trunk/src/reglookup.c

    r182 r184  
    5454void printValue(REGFI_ITERATOR* iter, const REGFI_VK_REC* vk, char* prefix)
    5555{
    56   REGFI_DATA* data;
     56  const REGFI_DATA* data;
    5757  char* quoted_value = NULL;
    5858  char* quoted_name = NULL;
     
    9595      fprintf(stderr, "WARN: While quoting value for '%s/%s', "
    9696              "warning returned: %s\n", prefix, quoted_name, conv_error);
    97     regfi_free_data(data);
     97    regfi_free_record(data);
    9898  }
    9999
     
    275275void printValueList(REGFI_ITERATOR* iter, char* prefix)
    276276{
    277   REGFI_VK_REC* value;
     277  const REGFI_VK_REC* value;
    278278
    279279  value = regfi_iterator_first_value(iter);
     
    282282    if(!type_filter_enabled || (value->type == type_filter))
    283283      printValue(iter, value, prefix);
    284     regfi_free_value(value);
     284    regfi_free_record(value);
    285285    value = regfi_iterator_next_value(iter);
    286286    printMsgs(iter->f);
     
    299299  char* quoted_classname;
    300300  const REGFI_SK_REC* sk;
    301   const REGFI_NK_REC* k = regfi_iterator_cur_key(iter);
    302   REGFI_CLASSNAME* classname;
    303 
    304   formatTime(&k->mtime, mtime);
     301  const REGFI_NK_REC* key = regfi_iterator_cur_key(iter);
     302  const REGFI_CLASSNAME* classname;
     303
     304  formatTime(&key->mtime, mtime);
    305305
    306306  if(print_security && (sk=regfi_iterator_cur_sk(iter)))
     
    310310    sacl = regfi_get_sacl(sk->sec_desc);
    311311    dacl = regfi_get_dacl(sk->sec_desc);
     312    regfi_free_record(sk);
     313
    312314    if(owner == NULL)
    313315      owner = empty_str;
     
    319321      dacl = empty_str;
    320322
    321     classname = regfi_iterator_fetch_classname(iter, k);
     323    classname = regfi_iterator_fetch_classname(iter, key);
    322324    printMsgs(iter->f);
    323325    if(classname != NULL)
     
    343345    else
    344346      quoted_classname = empty_str;
    345     regfi_free_classname(classname);
     347    regfi_free_record(classname);
    346348
    347349    printMsgs(iter->f);
     
    362364  else
    363365    printf("%s,KEY,,%s\n", full_path, mtime);
     366
     367  regfi_free_record(key);
    364368}
    365369
     
    369373  const REGFI_NK_REC* root = NULL;
    370374  const REGFI_NK_REC* cur = NULL;
    371   REGFI_NK_REC* sub = NULL;
     375  const REGFI_NK_REC* sub = NULL;
    372376  char* path = NULL;
    373377  int key_type = regfi_type_str2val("KEY");
     
    430434
    431435      cur = regfi_iterator_cur_key(iter);
    432       regfi_free_key(sub);
     436      regfi_free_record(sub);
    433437      sub = regfi_iterator_first_subkey(iter);
    434438      print_this = true;
     
    453457int retrievePath(REGFI_ITERATOR* iter, char** path)
    454458{
    455   REGFI_VK_REC* value;
     459  const REGFI_VK_REC* value;
    456460  char* tmp_path_joined;
    457461  const char** tmp_path;
     
    508512      printValue(iter, value, tmp_path_joined);
    509513
    510     regfi_free_value(value);
     514    regfi_free_record(value);
    511515    free(tmp_path);
    512516    free(tmp_path_joined);
Note: See TracChangeset for help on using the changeset viewer.