#define CTDB_NO_MEMORY(ctdb, p) do { if (!(p)) { \
++ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
return -1; }} while (0)
#define CTDB_NO_MEMORY_VOID(ctdb, p) do { if (!(p)) { \
++ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
}} while (0)
#define CTDB_NO_MEMORY_NULL(ctdb, p) do { if (!(p)) { \
++ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
ctdb_set_error(ctdb, "Out of memory at %s:%d", __FILE__, __LINE__); \
return NULL; }} while (0)
#define CTDB_NO_MEMORY_FATAL(ctdb, p) do { if (!(p)) { \
++ DEBUG(0,("Out of memory for %s at %s\n", #p, __location__)); \
ctdb_fatal(ctdb, "Out of memory in " __location__ ); \
}} while (0)
generation = strtoul(argv[1], NULL, 0);
num_nodes = strtoul(argv[2], NULL, 0);
- vnnmap = talloc_zero_size(ctdb, offsetof(struct ctdb_vnn_map, map) + 4*num_nodes);
- if (vnnmap == NULL) {
- DEBUG(0,(__location__ " Unable to allocate vnn_map structure\n"));
- exit(1);
- }
+ vnnmap = talloc(ctdb, struct ctdb_vnn_map);
- if (vnnmap == NULL) {
- DEBUG(0,(__location__ " Unable to allocate vnn_map structure\n"));
- exit(1);
- }
++ CTDB_NO_MEMORY(ctdb, vnnmap);
++
vnnmap->generation = generation;
vnnmap->size = num_nodes;
- if (vnnmap->map == NULL) {
- DEBUG(0,(__location__ " Unable to allocate vnn_map->map array\n"));
- exit(1);
- }
+ vnnmap->map = talloc_array(vnnmap, uint32_t, vnnmap->size);
++ CTDB_NO_MEMORY(ctdb, vnnmap->map);
+
for (i=0;i<vnnmap->size;i++) {
vnnmap->map[i] = strtoul(argv[3+i], NULL, 0);
}