home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / file / managers / mc-3.2 / mc-3 / mc-3.2.1 / slang / slmemset.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-17  |  880 b   |  41 lines

  1. /* Copyright (c) 1992, 1995 John E. Davis
  2.  * All rights reserved.
  3.  * 
  4.  * You may distribute under the terms of either the GNU General Public
  5.  * License or the Perl Artistic License.
  6.  */
  7.  
  8.  
  9. /* These routines are fast memcpy, memset routines.  When available, I
  10.    use system rouines.  For msdos, I use inline assembly. */
  11.  
  12. /* The current versions only work in the forward direction only!! */
  13.       
  14. #include <stdio.h>
  15. #include "slang.h"
  16. #include "_slang.h"
  17.  
  18. void jed_memset(char *p, char space, int n)
  19. {
  20. #if !defined(msdos) || defined(__WIN32__)
  21.    register char *pmax;
  22.  
  23.    pmax = p + (n - 4);
  24.    n = n % 4;
  25.    while(p <= pmax) 
  26.      {
  27.     *p = space; *(p + 1) = space; *(p + 2) = space; *(p + 3) = space;
  28.     p += 4;
  29.      }
  30.    while (n--) *p++ = space;
  31. #else
  32.    asm mov al, space
  33.    asm mov dx, di
  34.    asm mov cx, n
  35.    asm les di, p
  36.    asm cld
  37.    asm rep stosb
  38.    asm mov di, dx
  39. #endif
  40. }
  41.