home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / CLISP-2.LHA / CLISP960530-ki.lha / ffcall / avcall / structcpy.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-15  |  831 b   |  30 lines

  1. /* copy structs */
  2.  
  3. /*
  4.  * Copyright 1995 Bruno Haible, <haible@ma2s2.mathematik.uni-karlsruhe.de>
  5.  *
  6.  * This is free software distributed under the GNU General Public Licence
  7.  * described in the file COPYING. Contact the author if you don't have this
  8.  * or can't live with it. There is ABSOLUTELY NO WARRANTY, explicit or implied,
  9.  * on this software.
  10.  */
  11.  
  12. void __structcpy(dest,src,size,alignment)
  13.   void* dest;
  14.   void* src;
  15.   unsigned long size;
  16.   unsigned long alignment;
  17. {
  18.   if (alignment % sizeof(long))
  19.     { char* d = (char*)dest;
  20.       char* s = (char*)src;
  21.       do { *d++ = *s++; } while (--size > 0);
  22.     }
  23.   else
  24.     /* If the alignment is a multiple of sizeof(long), the size is as well. */
  25.     { long* d = (long*)dest;
  26.       long* s = (long*)src;
  27.       do { *d++ = *s++; } while ((size -= sizeof(long)) > 0);
  28.     }
  29. }
  30.