aboutsummaryrefslogtreecommitdiff
path: root/common.h
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2013-01-07 18:09:32 +0100
committerPetr Machata <pmachata@redhat.com>2013-03-08 22:55:31 +0100
commitb1ab2aefa199ea8e14e29bac78ae71030c2d4863 (patch)
treedaf37ac44f5b412fc2788708abf1effcf721b7df /common.h
parent395a4e3ad6b03949fbe0a2818bfdec738da1c281 (diff)
downloadltrace-b1ab2aefa199ea8e14e29bac78ae71030c2d4863.tar.gz
Consolidate two duplicate conditional strdup wrappers to strdup_if
- Convert callers in prototype.c and library.c - Current placement in library.c is somewhat arbitrary. There currently doesn't seem to be a more suitable place. - The behavior subtly changed: in case of failure, RET is now unaffected.
Diffstat (limited to 'common.h')
-rw-r--r--common.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/common.h b/common.h
index 637f041..a53c5db 100644
--- a/common.h
+++ b/common.h
@@ -1,6 +1,6 @@
/*
* This file is part of ltrace.
- * Copyright (C) 2011,2012 Petr Machata, Red Hat Inc.
+ * Copyright (C) 2011,2012,2013 Petr Machata, Red Hat Inc.
* Copyright (C) 2010 Joe Damato
* Copyright (C) 2009 Juan Cespedes
*
@@ -66,4 +66,9 @@ struct library_symbol;
int format_argument(FILE *stream, struct value *value,
struct value_dict *arguments);
+/* Set *RET to either a duplicate of STR (if WHETHER), or STR
+ * (otherwise). Return 0 on success or a negative value on failure.
+ * The duplication is not done if STR is NULL. */
+int strdup_if(const char **ret, const char *str, int whether);
+
#endif