You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
515 B

  1. /* See LICENSE file for copyright and license details. */
  2. #include <stdarg.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include "util.h"
  7. void *
  8. ecalloc(size_t nmemb, size_t size)
  9. {
  10. void *p;
  11. if (!(p = calloc(nmemb, size)))
  12. perror(NULL);
  13. return p;
  14. }
  15. void
  16. die(const char *fmt, ...) {
  17. va_list ap;
  18. va_start(ap, fmt);
  19. vfprintf(stderr, fmt, ap);
  20. va_end(ap);
  21. if (fmt[0] && fmt[strlen(fmt)-1] == ':') {
  22. fputc(' ', stderr);
  23. perror(NULL);
  24. } else {
  25. fputc('\n', stderr);
  26. }
  27. exit(1);
  28. }