summaryrefslogtreecommitdiff
path: root/bench/wtperf/wtperf.h
diff options
context:
space:
mode:
authorDavid Hows <howsdav@gmail.com>2016-01-12 15:52:10 +1100
committerDavid Hows <howsdav@gmail.com>2016-01-13 10:54:17 +1100
commit312a3722a7e3774489f2b303b03e3c0d882dcc59 (patch)
tree59b393effa70970c19a869dca06f84dba6c9edc6 /bench/wtperf/wtperf.h
parente35c23e539095f6a1c39f10cba07ec6da52cd56c (diff)
downloadmongo-312a3722a7e3774489f2b303b03e3c0d882dcc59.tar.gz
WT-2326 - Add dcalloc, dmalloc and dstrdup to wtperf and replace all existing malloc, calloc and strncpy calls
Diffstat (limited to 'bench/wtperf/wtperf.h')
-rw-r--r--bench/wtperf/wtperf.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/bench/wtperf/wtperf.h b/bench/wtperf/wtperf.h
index 8a9be7a0938..9351ca0285e 100644
--- a/bench/wtperf/wtperf.h
+++ b/bench/wtperf/wtperf.h
@@ -289,7 +289,6 @@ void latency_insert(CONFIG *, uint32_t *, uint32_t *, uint32_t *);
void latency_read(CONFIG *, uint32_t *, uint32_t *, uint32_t *);
void latency_update(CONFIG *, uint32_t *, uint32_t *, uint32_t *);
void latency_print(CONFIG *);
-int enomem(const CONFIG *);
int run_truncate(
CONFIG *, CONFIG_THREAD *, WT_CURSOR *, WT_SESSION *, int *);
int setup_log_file(CONFIG *);
@@ -323,4 +322,55 @@ extract_key(char *key_buf, uint64_t *keynop)
sscanf(key_buf, "%" SCNu64, keynop);
}
+/*
+ * die --
+ * Print message and exit on failure.
+ */
+static inline void
+die(int e, const char *str)
+{
+ fprintf(stderr, "Call to %s failed: %s", str, wiredtiger_strerror(e));
+ exit(EXIT_FAILURE);
+}
+
+/*
+ * dmalloc --
+ * Call malloc, dying on failure.
+ */
+static inline void *
+dmalloc(size_t len)
+{
+ void *p;
+
+ if ((p = malloc(len)) == NULL)
+ die(errno, "malloc");
+ return (p);
+}
+
+/*
+ * dstrdup --
+ * Call strdup, dying on failure.
+ */
+static inline char *
+dstrdup(const char *str)
+{
+ char *p;
+
+ if ((p = strdup(str)) == NULL)
+ die(errno, "strdup");
+ return (p);
+}
+/*
+ * dcalloc --
+ * Call calloc, dying on failure.
+ */
+static inline void *
+dcalloc(size_t num, size_t len)
+{
+ void *p;
+
+ if ((p = calloc(len, num)) == NULL)
+ die(errno, "calloc");
+ return (p);
+}
#endif