My dmenu build
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 
 

69 righe
940 B

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