summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-02-17 22:21:41 -0800
committerOri Bernstein <ori@eigenstate.org>2017-02-17 23:32:19 -0800
commit61a91a2cc9be621ee517b2cb4114922bd5da351f (patch)
tree2dbf60c0c0d4b03c65c59146f44e4f7c8f1c9cb2 /util
parent210b24e9cf07baef21fb0fd943f81f38a3196945 (diff)
downloadmc-61a91a2cc9be621ee517b2cb4114922bd5da351f.tar.gz
Search for usefiles relative to the output.
For most uses, this is equivalent to compiler cwd, but supports out of tree builds better. It also means that builds behave the same way regardless of the directory that the compiler is run from, which is convenient for testing. This also drops support for `.use` suffixes on local uses.
Diffstat (limited to 'util')
-rw-r--r--util/util.c10
-rw-r--r--util/util.h1
2 files changed, 11 insertions, 0 deletions
diff --git a/util/util.c b/util/util.c
index dccc90b..904ef26 100644
--- a/util/util.c
+++ b/util/util.c
@@ -24,6 +24,16 @@ char *strdupn(char *s, size_t len)
return ret;
}
+char *xstrdup(char *s)
+{
+ char *p;
+
+ p = strdup(s);
+ if (!p && s)
+ die("Out of memory");
+ return p;
+}
+
char *strjoin(char *u, char *v)
{
size_t n;
diff --git a/util/util.h b/util/util.h
index 60a344b..49f10d6 100644
--- a/util/util.h
+++ b/util/util.h
@@ -121,6 +121,7 @@ void *zrealloc(void *p, size_t oldsz, size_t size);
void *xrealloc(void *p, size_t size);
void die(char *msg, ...) FATAL;
char *strdupn(char *s, size_t len);
+char *xstrdup(char *s);
char *strjoin(char *u, char *v);
void *memdup(void *mem, size_t len);
size_t bprintf(char *buf, size_t len, char *fmt, ...);