if (rec.dsize < sizeof(*header)) {
/* return an initial header */
ltdb_initial_header(ctdb, key, header);
if (rec.dsize < sizeof(*header)) {
/* return an initial header */
ltdb_initial_header(ctdb, key, header);
data->dptr = NULL;
data->dsize = 0;
return 0;
data->dptr = NULL;
data->dsize = 0;
return 0;
data->dsize = rec.dsize - sizeof(struct ctdb_ltdb_header);
data->dptr = talloc_memdup(ctdb, sizeof(struct ctdb_ltdb_header)+rec.dptr,
data->dsize);
data->dsize = rec.dsize - sizeof(struct ctdb_ltdb_header);
data->dptr = talloc_memdup(ctdb, sizeof(struct ctdb_ltdb_header)+rec.dptr,
data->dsize);
CTDB_NO_MEMORY(ctdb, data->dptr);
return 0;
CTDB_NO_MEMORY(ctdb, data->dptr);
return 0;
- rec.dsize = sizeof(struct ctdb_ltdb_header) + data.dsize;
+ rec.dsize = sizeof(*header) + data.dsize;
rec.dptr = talloc_size(ctdb, rec.dsize);
CTDB_NO_MEMORY(ctdb, rec.dptr);
rec.dptr = talloc_size(ctdb, rec.dsize);
CTDB_NO_MEMORY(ctdb, rec.dptr);
+/* free memory if the pointer is valid and zero the pointer */
+#ifndef SAFE_FREE
+#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
+#endif
+
/* internal prototypes */
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);
/* internal prototypes */
void ctdb_set_error(struct ctdb_context *ctdb, const char *fmt, ...);
void ctdb_fatal(struct ctdb_context *ctdb, const char *msg);