memswap.c.html 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. memswap.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='memout.c.html' title=' memout.c '>PREV</a>]
  17. [<a href='toolkit.html' title=' Index '>HOME</a>]
  18. [<a href='mme.c.html' title=' mme.c '>NEXT</a>]
  19. </div>
  20. <pre>
  21. /*====================================================================*
  22. *
  23. * void memswap (void * memory1, void * memory2, size_t extent);
  24. *
  25. * memory.h
  26. *
  27. * exchange the contents of one memory region with that of another;
  28. * return no value;
  29. *
  30. * one application for this function is to exchange the source and
  31. * destination addresses in an Ethernet frame to form a response
  32. * message;
  33. *
  34. * Motley Tools by Charles Maier &lt;cmaier@cmassoc.net&gt;;
  35. * Copyright (c) 2001-2006 by Charles Maier Associates;
  36. * Licensed under the Internet Software Consortium License;
  37. *
  38. *--------------------------------------------------------------------*/
  39. #ifndef MEMSWAP_SOURCE
  40. #define MEMSWAP_SOURCE
  41. #include &quot;../tools/memory.h&quot;
  42. void memswap (void * memory1, void * memory2, size_t extent)
  43. {
  44. register byte * byte1 = (byte *)(memory1);
  45. register byte * byte2 = (byte *)(memory2);
  46. if (memory1 != memory2) while (extent--)
  47. {
  48. byte byte = *byte1;
  49. *byte1++ = *byte2;
  50. *byte2++ = byte;
  51. }
  52. return;
  53. }
  54. #endif
  55. </pre>
  56. <div class='footerlink'>
  57. [<a href='memout.c.html' title=' memout.c '>PREV</a>]
  58. [<a href='toolkit.html' title=' Index '>HOME</a>]
  59. [<a href='mme.c.html' title=' mme.c '>NEXT</a>]
  60. </div>
  61. </body>
  62. </html>