* this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "includes.h"
+#include "replace.h"
#include "system/shmem.h"
#include "system/filesys.h"
-#if _SAMBA_BUILD_ == 3
-#undef malloc
-#undef realloc
-#endif
+#include <talloc.h>
+#include "lib/util/samba_util.h"
+#include "lib/util/debug.h"
/**
* @file
}
#endif
if (!p) {
- p = file_load(fname, &s2, 0, talloc_autofree_context());
+ p = file_load(fname, &s2, 0, NULL);
if (!p) return NULL;
if (s2 != size) {
DEBUG(1,("incorrect size for %s - got %d expected %d\n",
}
+/*
+ compare two files, return true if the two files have the same content
+ */
+bool file_compare(const char *path1, const char *path2)
+{
+ size_t size1, size2;
+ char *p1, *p2;
+ TALLOC_CTX *mem_ctx = talloc_new(NULL);
+
+ p1 = file_load(path1, &size1, 0, mem_ctx);
+ p2 = file_load(path2, &size2, 0, mem_ctx);
+ if (!p1 || !p2 || size1 != size2) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+ if (memcmp(p1, p2, size1) != 0) {
+ talloc_free(mem_ctx);
+ return false;
+ }
+ talloc_free(mem_ctx);
+ return true;
+}