aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/secstore/util.c
blob: d791bc72325fa53d9ca8aff019d4f93771efc8a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <u.h>
#include <libc.h>

void *
emalloc(ulong n)
{
	void *p = malloc(n);
	if(p == nil)
		sysfatal("emalloc");
	memset(p, 0, n);
	return p;
}

void *
erealloc(void *p, ulong n)
{
	if ((p = realloc(p, n)) == nil)
		sysfatal("erealloc");
	return p;
}

char *
estrdup(char *s)
{
	if ((s = strdup(s)) == nil)
		sysfatal("estrdup");
	return s;
}

char *
getpassm(char *prompt)
{
	char *p = getpass(prompt);

	if(p == nil || (p = strdup(p)) == nil)
		sysfatal("getpassm");
	return p;
}