memincr.c.html 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. memincr.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='memencode.c.html' title=' memencode.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='memout.c.html' title=' memout.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * signed memincr (void * memory, size_t extent);
  24. *
  25. * memory.h
  26. *
  27. * increment a multi-byte memory region; start at 0x00 and reset
  28. * at 0xFF; return -1 if all bytes are 0xFF;
  29. *
  30. * for example,
  31. *
  32. * 0x00 0x00 0x00 --&gt; 0x00 0x00 0x01
  33. * 0xFF 0x00 0xFF --&gt; 0xFF 0x01 0x00
  34. *
  35. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  36. * Copyright (c) 2001-2006 by Charles Maier Associates;
  37. * Licensed under the Internet Software Consortium License;
  38. *
  39. *--------------------------------------------------------------------*/
  40. #ifndef MEMINCR_SOURCE
  41. #define MEMINCR_SOURCE
  42. #include &quot;../tools/memory.h&quot;
  43. signed memincr (void * memory, register size_t extent)
  44. {
  45. register byte * offset = (byte *)(memory);
  46. while (extent--)
  47. {
  48. if (++ offset [extent] != 0x00)
  49. {
  50. return (0);
  51. }
  52. }
  53. return (-1);
  54. }
  55. #endif
  56. </pre>
  57. <div class='footerlink'>
  58. [<a href='memencode.c.html' title=' memencode.c '>PREV</a>]
  59. [<a href='toolkit.html' title=' Index '>HOME</a>]
  60. [<a href='memout.c.html' title=' memout.c '>NEXT</a>]
  61. </div>
  62. </body>
  63. </html>