aux.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <auth.h>
  12. #include <fcall.h>
  13. #include <thread.h>
  14. #include "9p.h"
  15. void*
  16. emalloc9p(uint32_t sz)
  17. {
  18. void *v;
  19. if((v = malloc(sz)) == nil) {
  20. fprint(2, "out of memory allocating %lu\n", sz);
  21. exits("mem");
  22. }
  23. memset(v, 0, sz);
  24. setmalloctag(v, getcallerpc());
  25. return v;
  26. }
  27. void*
  28. erealloc9p(void *v, uint32_t sz)
  29. {
  30. if((v = realloc(v, sz)) == nil) {
  31. fprint(2, "out of memory allocating %lu\n", sz);
  32. exits("mem");
  33. }
  34. setrealloctag(v, getcallerpc());
  35. return v;
  36. }
  37. char*
  38. estrdup9p(char *s)
  39. {
  40. char *t;
  41. if((t = strdup(s)) == nil) {
  42. fprint(2, "out of memory in strdup(%.10s)\n", s);
  43. exits("mem");
  44. }
  45. setmalloctag(t, getcallerpc());
  46. return t;
  47. }