summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2001-10-22 02:38:45 +0000
committerJeremy Allison <jra@samba.org>2001-10-22 02:38:45 +0000
commitc032c2b36432d91cab4dbaf1ea4009b1194c4ccc (patch)
tree974826a193d085d61cdda01a1b97c29d9407385e /source3
parent96ef1b0eb2d408a4ac9f7cc1b7c1bfe53252715d (diff)
downloadsamba-c032c2b36432d91cab4dbaf1ea4009b1194c4ccc.tar.gz
samba-c032c2b36432d91cab4dbaf1ea4009b1194c4ccc.tar.bz2
samba-c032c2b36432d91cab4dbaf1ea4009b1194c4ccc.zip
Added xstrdup, removed static version from smbpasswd.c
Jeremy. (This used to be commit d01a9e5974d80ee8be2f7a20aeaae5826325d035)
Diffstat (limited to 'source3')
-rw-r--r--source3/lib/util.c16
-rw-r--r--source3/utils/smbpasswd.c14
2 files changed, 14 insertions, 16 deletions
diff --git a/source3/lib/util.c b/source3/lib/util.c
index cd170ff3d3..90bb462d0e 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1649,9 +1649,9 @@ void *xmalloc(size_t size)
{
void *p;
if (size == 0)
- smb_panic("xmalloc called with zero size.\n");
+ smb_panic("xmalloc: called with zero size.\n");
if ((p = malloc(size)) == NULL)
- smb_panic("xmalloc malloc fail.\n");
+ smb_panic("xmalloc: malloc fail.\n");
return p;
}
@@ -1668,6 +1668,18 @@ void *xmemdup(void *p, size_t size)
}
/*****************************************************************
+ strdup that aborts on malloc fail.
+ *****************************************************************/
+
+char *xstrdup(const char *s)
+{
+ char *s1 = strdup(s);
+ if (!s1)
+ smb_panic("xstrdup: malloc fail\n");
+ return s1;
+}
+
+/*****************************************************************
like strdup but for memory
*****************************************************************/
void *memdup(void *p, size_t size)
diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c
index 13ca1c0d71..c5aafeb723 100644
--- a/source3/utils/smbpasswd.c
+++ b/source3/utils/smbpasswd.c
@@ -34,20 +34,6 @@ extern int optind;
static BOOL local_mode;
/*********************************************************
-a strdup with exit
-**********************************************************/
-static char *xstrdup(char *s)
-{
- s = strdup(s);
- if (!s) {
- fprintf(stderr,"out of memory\n");
- exit(1);
- }
- return s;
-}
-
-
-/*********************************************************
Print command usage on stderr and die.
**********************************************************/
static void usage(void)