-
Notifications
You must be signed in to change notification settings - Fork 60
Expand file tree
/
Copy pathutil.c
More file actions
41 lines (33 loc) · 725 Bytes
/
util.c
File metadata and controls
41 lines (33 loc) · 725 Bytes
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
39
40
/*
* ECFS (Extended core file snapshot) utility (C) 2014 Ryan O'Neill
* http://www.bitlackeys.org/#research
* elfmaster@zoho.com
*/
#include "ecfs.h"
void * heapAlloc(size_t len)
{
void *p = malloc(len);
if (p == NULL) {
perror("malloc");
exit(-1);
}
return (void *)(uintptr_t)p;
}
char * xstrdup(const char *s)
{
char *p = strdup(s);
if (p == NULL) {
perror("strdup");
exit(-1);
}
return p;
}
char * xfmtstrdup(char *fmt, ...)
{
char *s, buf[512];
va_list va;
va_start (va, fmt);
vsnprintf (buf, sizeof(buf), fmt, va);
s = (char *)(uintptr_t)xstrdup(buf);
return s;
}