Index: trunk/include/lru_cache.h
===================================================================
--- trunk/include/lru_cache.h	(revision 146)
+++ trunk/include/lru_cache.h	(revision 147)
@@ -1,4 +1,4 @@
 /*
- * Copyright (C) 2008 Timothy D. Morgan
+ * Copyright (C) 2008-2009 Timothy D. Morgan
  *
  * This program is free software; you can redistribute it and/or modify
@@ -27,4 +27,5 @@
 #include <string.h>
 #include <unistd.h>
+#include "talloc.h"
 
 struct lru_cache_element;
@@ -50,13 +51,15 @@
   lru_cache_element* newest;
   lru_cache_element** table;
-  bool free_data;
+  bool talloc_data;
 } lru_cache;
 
 
-lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret, bool free_data);
+lru_cache* lru_cache_create(uint32_t max_keys, uint32_t secret);
+lru_cache* lru_cache_create_ctx(void* talloc_ctx, uint32_t max_keys, 
+				uint32_t secret, bool talloc_data);
 void lru_cache_destroy(lru_cache* ht);
 
-/* Returns a pointer to the old, replaced data stored at index.  
- * Returns NULL if no entry was overwritten.
+/* 
+ * 
  */
 bool lru_cache_update(lru_cache* ht, const void* index, 
Index: trunk/include/regfi.h
===================================================================
--- trunk/include/regfi.h	(revision 146)
+++ trunk/include/regfi.h	(revision 147)
@@ -46,4 +46,5 @@
 #include <assert.h>
 
+#include "talloc.h"
 #include "smb_deps.h"
 #include "winsec.h"
@@ -84,6 +85,4 @@
 #define REG_KEY                    0x7FFFFFFF
 
-#define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
-#define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
 #define REGFI_MAX_DEPTH		   512
 #define REGFI_OFFSET_NONE          0xffffffff
@@ -93,4 +92,6 @@
 
 /* Header sizes and magic number lengths for various records */
+#define REGFI_HBIN_ALLOC           0x1000 /* Minimum allocation unit for HBINs */
+#define REGFI_REGF_SIZE            0x1000 /* "regf" header block size */
 #define REGFI_REGF_MAGIC_SIZE      4
 #define REGFI_HBIN_MAGIC_SIZE      4
@@ -107,5 +108,5 @@
  *      been reported that Windows timestamps are never more than a
  *      certain granularity (250ms?), which could be used to help
- *      eliminate false positives.  Would need to validate this and
+ *      eliminate false positives.  Would need to verify this and
  *      perhaps conservatively implement a check.
  */
Index: trunk/include/talloc.h
===================================================================
--- trunk/include/talloc.h	(revision 147)
+++ trunk/include/talloc.h	(revision 147)
@@ -0,0 +1,162 @@
+/* 
+   Unix SMB/CIFS implementation.
+   Samba temporary memory allocation functions
+
+   Copyright (C) Andrew Tridgell 2004-2005
+   Copyright (C) Stefan Metzmacher 2006
+   Copyright (C) Timothy D. Morgan 2009 
+   
+     ** NOTE! The following LGPL license applies to the talloc library.
+     ** This does NOT imply that all of reglookup is released under the LGPL
+   
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 3 of the License, or (at your option) any later version.
+
+   This library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with this library; if not, see <http://www.gnu.org/licenses/>.
+*/
+/* $Id$ */
+
+#ifndef _TALLOC_H_
+#define _TALLOC_H_
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdbool.h>
+#include "smb_deps.h" /* MAX macro */
+
+/*
+  this uses a little trick to allow __LINE__ to be stringified
+*/
+#ifndef __location__
+#define __TALLOC_STRING_LINE1__(s)    #s
+#define __TALLOC_STRING_LINE2__(s)   __TALLOC_STRING_LINE1__(s)
+#define __TALLOC_STRING_LINE3__  __TALLOC_STRING_LINE2__(__LINE__)
+#define __location__ __FILE__ ":" __TALLOC_STRING_LINE3__
+#endif
+
+#ifndef TALLOC_DEPRECATED
+#define TALLOC_DEPRECATED 0
+#endif
+
+#ifndef PRINTF_ATTRIBUTE
+#if (__GNUC__ >= 3)
+/** Use gcc attribute to check printf fns.  a1 is the 1-based index of
+ * the parameter containing the format, and a2 the index of the first
+ * argument. Note that some gcc 2.x versions don't handle this
+ * properly **/
+#define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
+#else
+#define PRINTF_ATTRIBUTE(a1, a2)
+#endif
+#endif
+
+#define talloc_set_destructor(ptr, function) \
+	_talloc_set_destructor((ptr), (int (*)(void *))(function))
+#define _TALLOC_TYPEOF(ptr) void *
+#define talloc_steal(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_steal((ctx),(ptr))
+
+#define talloc_reference(ctx, ptr) (_TALLOC_TYPEOF(ptr))_talloc_reference((ctx),(ptr))
+#define talloc_move(ctx, ptr) (_TALLOC_TYPEOF(*(ptr)))_talloc_move((ctx),(void *)(ptr))
+
+/* useful macros for creating type checked pointers */
+#define talloc(ctx, type) (type *)talloc_named_const(ctx, sizeof(type), #type)
+#define talloc_size(ctx, size) talloc_named_const(ctx, size, __location__)
+#define talloc_ptrtype(ctx, ptr) (_TALLOC_TYPEOF(ptr))talloc_size(ctx, sizeof(*(ptr)))
+
+#define talloc_new(ctx) talloc_named_const(ctx, 0, "talloc_new: " __location__)
+
+#define talloc_zero(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
+#define talloc_zero_size(ctx, size) _talloc_zero(ctx, size, __location__)
+
+#define talloc_zero_array(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
+#define talloc_array(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
+#define talloc_array_size(ctx, size, count) _talloc_array(ctx, size, count, __location__)
+#define talloc_array_ptrtype(ctx, ptr, count) (_TALLOC_TYPEOF(ptr))talloc_array_size(ctx, sizeof(*(ptr)), count)
+
+#define talloc_realloc(ctx, p, type, count) (type *)_talloc_realloc_array(ctx, p, sizeof(type), count, #type)
+#define talloc_realloc_size(ctx, ptr, size) _talloc_realloc(ctx, ptr, size, __location__)
+
+#define talloc_memdup(t, p, size) _talloc_memdup(t, p, size, __location__)
+
+#define talloc_set_type(ptr, type) talloc_set_name_const(ptr, #type)
+#define talloc_get_type(ptr, type) (type *)talloc_check_name(ptr, #type)
+
+#define talloc_find_parent_bytype(ptr, type) (type *)talloc_find_parent_byname(ptr, #type)
+
+/* The following definitions come from talloc.c  */
+void *_talloc(const void *context, size_t size);
+void *talloc_pool(const void *context, size_t size);
+void _talloc_set_destructor(const void *ptr, int (*destructor)(void *));
+int talloc_increase_ref_count(const void *ptr);
+size_t talloc_reference_count(const void *ptr);
+void *_talloc_reference(const void *context, const void *ptr);
+int talloc_unlink(const void *context, void *ptr);
+const char *talloc_set_name(const void *ptr, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+void talloc_set_name_const(const void *ptr, const char *name);
+void *talloc_named(const void *context, size_t size, 
+		   const char *fmt, ...) PRINTF_ATTRIBUTE(3,4);
+void *talloc_named_const(const void *context, size_t size, const char *name);
+const char *talloc_get_name(const void *ptr);
+void *talloc_check_name(const void *ptr, const char *name);
+void *talloc_parent(const void *ptr);
+const char *talloc_parent_name(const void *ptr);
+void *talloc_init(const char *fmt, ...) PRINTF_ATTRIBUTE(1,2);
+int talloc_free(void *ptr);
+void talloc_free_children(void *ptr);
+void *_talloc_realloc(const void *context, void *ptr, size_t size, const char *name);
+void *_talloc_steal(const void *new_ctx, const void *ptr);
+void *_talloc_move(const void *new_ctx, const void *pptr);
+size_t talloc_total_size(const void *ptr);
+size_t talloc_total_blocks(const void *ptr);
+void talloc_report_depth_cb(const void *ptr, int depth, int max_depth,
+			    void (*callback)(const void *ptr,
+			  		     int depth, int max_depth,
+					     int is_ref,
+					     void *private_data),
+			    void *private_data);
+void talloc_report_depth_file(const void *ptr, int depth, int max_depth, FILE *f);
+void talloc_report_full(const void *ptr, FILE *f);
+void talloc_report(const void *ptr, FILE *f);
+void talloc_enable_null_tracking(void);
+void talloc_disable_null_tracking(void);
+void talloc_enable_leak_report(void);
+void talloc_enable_leak_report_full(void);
+void *_talloc_zero(const void *ctx, size_t size, const char *name);
+void *_talloc_memdup(const void *t, const void *p, size_t size, const char *name);
+void *_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_zero_array(const void *ctx, size_t el_size, unsigned count, const char *name);
+void *_talloc_realloc_array(const void *ctx, void *ptr, size_t el_size, unsigned count, const char *name);
+void *talloc_realloc_fn(const void *context, void *ptr, size_t size);
+void *talloc_autofree_context(void);
+size_t talloc_get_size(const void *ctx);
+void *talloc_find_parent_byname(const void *ctx, const char *name);
+void talloc_show_parents(const void *context, FILE *file);
+int talloc_is_parent(const void *context, const void *ptr);
+
+char *talloc_strdup(const void *t, const char *p);
+char *talloc_strdup_append(char *s, const char *a);
+char *talloc_strdup_append_buffer(char *s, const char *a);
+
+char *talloc_strndup(const void *t, const char *p, size_t n);
+char *talloc_strndup_append(char *s, const char *a, size_t n);
+char *talloc_strndup_append_buffer(char *s, const char *a, size_t n);
+
+char *talloc_vasprintf(const void *t, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+char *talloc_vasprintf_append_buffer(char *s, const char *fmt, va_list ap) PRINTF_ATTRIBUTE(2,0);
+
+char *talloc_asprintf(const void *t, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+char *talloc_asprintf_append_buffer(char *s, const char *fmt, ...) PRINTF_ATTRIBUTE(2,3);
+
+#endif
Index: trunk/include/winsec.h
===================================================================
--- trunk/include/winsec.h	(revision 146)
+++ trunk/include/winsec.h	(revision 147)
@@ -42,4 +42,5 @@
 
 #include "smb_deps.h"
+#include "talloc.h"
 
 
@@ -145,11 +146,17 @@
 } WINSEC_DESC;
 
+WINSEC_DESC* winsec_parse_descriptor(const uint8_t* buf, uint32_t buf_len);
+void winsec_free_descriptor(WINSEC_DESC* desc);
 
-/* XXX: Need API functions to deallocate these structures */
-WINSEC_DESC* winsec_parse_desc(const uint8_t* buf, uint32_t buf_len);
-WINSEC_ACL* winsec_parse_acl(const uint8_t* buf, uint32_t buf_len);
-WINSEC_ACE* winsec_parse_ace(const uint8_t* buf, uint32_t buf_len);
-WINSEC_DOM_SID* winsec_parse_dom_sid(const uint8_t* buf, uint32_t buf_len);
-WINSEC_UUID* winsec_parse_uuid(const uint8_t* buf, uint32_t buf_len);
+WINSEC_DESC* winsec_parse_desc(void* talloc_ctx,
+			       const uint8_t* buf, uint32_t buf_len);
+WINSEC_ACL* winsec_parse_acl(void* talloc_ctx, 
+			     const uint8_t* buf, uint32_t buf_len);
+WINSEC_ACE* winsec_parse_ace(void* talloc_ctx, 
+			     const uint8_t* buf, uint32_t buf_len);
+WINSEC_DOM_SID* winsec_parse_dom_sid(void* talloc_ctx, 
+				     const uint8_t* buf, uint32_t buf_len);
+WINSEC_UUID* winsec_parse_uuid(void* talloc_ctx, 
+			       const uint8_t* buf, uint32_t buf_len);
 
 size_t winsec_sid_size(const WINSEC_DOM_SID* sid);
