My dmenu build
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.
 
 
 
 
 
 

48 lines
743 B

  1. /* (C)opyright MMVI Anselm R. Garbe <garbeam at gmail dot com>
  2. * See LICENSE file for license details.
  3. */
  4. #include "dmenu.h"
  5. #include <stdarg.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/wait.h>
  10. #include <unistd.h>
  11. /* static */
  12. static void
  13. badmalloc(unsigned int size) {
  14. eprint("fatal: could not malloc() %u bytes\n", size);
  15. }
  16. /* extern */
  17. void *
  18. emalloc(unsigned int size) {
  19. void *res = malloc(size);
  20. if(!res)
  21. badmalloc(size);
  22. return res;
  23. }
  24. void
  25. eprint(const char *errstr, ...) {
  26. va_list ap;
  27. va_start(ap, errstr);
  28. vfprintf(stderr, errstr, ap);
  29. va_end(ap);
  30. exit(EXIT_FAILURE);
  31. }
  32. char *
  33. estrdup(const char *str) {
  34. void *res = strdup(str);
  35. if(!res)
  36. badmalloc(strlen(str));
  37. return res;
  38. }