reverse.c.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. reverse.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='ResetDevice.c.html' title=' ResetDevice.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='reword.c.html' title=' reword.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void reverse (void * memory, size_t extent);
  24. *
  25. * reverse the order of bytes in a multi-byte memory region;
  26. *
  27. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  28. * Copyright (c) 2001-2006 by Charles Maier Associates;
  29. * Licensed under the Internet Software Consortium License;
  30. *
  31. *--------------------------------------------------------------------*/
  32. #ifndef REVERSE_SOURCE
  33. #define REVERSE_SOURCE
  34. #include &quot;../tools/memory.h&quot;
  35. void reverse (void * memory, size_t extent)
  36. {
  37. register byte * first = (byte *) (memory);
  38. register byte * final = first + extent;
  39. while (first &lt; final)
  40. {
  41. register byte byte = * first;
  42. * first++ = * -- final;
  43. * final = byte;
  44. }
  45. return;
  46. }
  47. #endif
  48. </pre>
  49. <div class='footerlink'>
  50. [<a href='ResetDevice.c.html' title=' ResetDevice.c '>PREV</a>]
  51. [<a href='toolkit.html' title=' Index '>HOME</a>]
  52. [<a href='reword.c.html' title=' reword.c '>NEXT</a>]
  53. </div>
  54. </body>
  55. </html>