"Fossies" - the Fresh Open Source Software Archive

Member "delegate9.9.13/maker/bcopy.c" (16 Aug 2009, 647 Bytes) of package /linux/misc/old/delegate9.9.13.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "bcopy.c" see the Fossies "Dox" file reference documentation.

    1 #include "ystring.h"
    2 
    3 int SUBST_bcopy = 1; /* bcopy(void*,void*,unsigned int*); */
    4 
    5 #if defined(__hpux__)
    6 #define TSZ unsigned long
    7 #else
    8 #define TSZ unsigned int
    9 #endif
   10 
   11 void bcopy(const void *b1,void *b2,TSZ length)
   12 {   int i;
   13     const char *t1;
   14     char *t2;
   15 
   16     if( b2 == b1 )
   17         return;
   18     if( b2 < b1 )
   19     for( i = 0; i < length; i++ )
   20         ((char*)b2)[i] = ((char*)b1)[i];
   21     else{
   22         t1 = (char*)b1 + length - 1;
   23         t2 = (char*)b2 + length - 1;
   24         for( i = 0; i < length; i++ )
   25             *t2-- = *t1--;
   26     }
   27 }
   28 
   29 int bcmp(const void *b1,const void *b2,TSZ length)
   30 {   int i;
   31 
   32     for( i = 0; i < length; i++) 
   33         if( ((char*)b1)[i] != ((char*)b2)[i] )
   34             return 1;
   35     return 0;
   36 }