diff options
author | Elliott Hughes <enh@google.com> | 2018-03-28 23:25:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2018-03-28 23:25:24 +0000 |
commit | 539f3ddff5ffb124fa75d4557647092d601d9d69 (patch) | |
tree | 9a1d557ed5a637649f4d77940de0662fc75217ef /fastboot/util.cpp | |
parent | 45562bfb63e2bbdcb315f16a0138eba1b0cb9928 (diff) | |
parent | 5620d224b605f7401b283fcbb456cca791762af3 (diff) |
Merge "Add "require partition-exists=" support."
Diffstat (limited to 'fastboot/util.cpp')
-rw-r--r-- | fastboot/util.cpp | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/fastboot/util.cpp b/fastboot/util.cpp index f2bbd3472..fb085e757 100644 --- a/fastboot/util.cpp +++ b/fastboot/util.cpp @@ -35,35 +35,24 @@ #include "fastboot.h" -double now() -{ +double now() { struct timeval tv; gettimeofday(&tv, NULL); return (double)tv.tv_sec + (double)tv.tv_usec / 1000000; } -char *mkmsg(const char *fmt, ...) -{ - char buf[256]; - char *s; - va_list ap; - - va_start(ap, fmt); - vsprintf(buf, fmt, ap); - va_end(ap); - - s = strdup(buf); - if (s == 0) die("out of memory"); - return s; -} - -void die(const char *fmt, ...) -{ +void die(const char* fmt, ...) { va_list ap; va_start(ap, fmt); fprintf(stderr,"error: "); vfprintf(stderr, fmt, ap); fprintf(stderr,"\n"); va_end(ap); - exit(1); + exit(EXIT_FAILURE); +} + +char* xstrdup(const char* s) { + char* result = strdup(s); + if (!result) die("out of memory"); + return result; } |