emalloc.c.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version='1.0' encoding='iso-8859-1'?>
  2. <!doctype html public '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
  3. <html xmlns='http://www.w3c.org/1999/xhtml' lang='en-us'>
  4. <head>
  5. <title>
  6. emalloc.c
  7. </title>
  8. <meta http-equiv='content-type' content='text/html;iso-8859-1'/>
  9. <meta name='generator' content='motley-tools 1.9.4 13:40:33 Feb 18 2015'/>
  10. <meta name='author' content='cmaier@cmassoc.net'/>
  11. <meta name='robots' content='noindex,nofollow'/>
  12. <link href='toolkit.css' rel='stylesheet' type='text/css'/>
  13. </head>
  14. <body>
  15. <div class='headerlink'>
  16. [<a href='efsu.c.html' title=' efsu.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='EmulateHost64.c.html' title=' EmulateHost64.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void * emalloc (size_t length)
  24. *
  25. * error.h
  26. *
  27. * attempt to allocate memory using malloc(); return the memory address
  28. * on success; print an error message on stderr and then terminate the
  29. * program on failure;
  30. *
  31. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  32. * Copyright (c) 2001-2006 by Charles Maier Associates;
  33. * Licensed under the Internet Software Consortium License;
  34. *
  35. *--------------------------------------------------------------------*/
  36. #ifndef EMALLOC_SOURCE
  37. #define EMALLOC_SOURCE
  38. #include &lt;stdio.h&gt;
  39. #include &lt;stdlib.h&gt;
  40. #include &lt;errno.h&gt;
  41. #include &quot;../tools/error.h&quot;
  42. void * emalloc (size_t length)
  43. {
  44. void * memory = malloc (length);
  45. if (!memory)
  46. {
  47. error (1, errno, &quot;need %lu bytes&quot;, (long)(length));
  48. }
  49. return (memory);
  50. }
  51. #endif
  52. </pre>
  53. <div class='footerlink'>
  54. [<a href='efsu.c.html' title=' efsu.c '>PREV</a>]
  55. [<a href='toolkit.html' title=' Index '>HOME</a>]
  56. [<a href='EmulateHost64.c.html' title=' EmulateHost64.c '>NEXT</a>]
  57. </div>
  58. </body>
  59. </html>