Changeset 184 for trunk/include


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

File:
1 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,
Note: See TracChangeset for help on using the changeset viewer.