home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / vc / pro3 / fmemops.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-25  |  2.3 KB  |  76 lines

  1. ===========================================================================
  2.  BBS: The Abacus * HST/DS * Potterville MI
  3. Date: 05-24-93 (05:42)             Number: 109
  4. From: BOB STOUT                    Refer#: 129
  5.   To: BOB CALBRIDGE                 Recvd: NO  
  6. Subj: Malloc                         Conf: (36) C Language
  7. ---------------------------------------------------------------------------
  8. In a message of <May 23 12:58>, Bob Calbridge (1:124/6300@fidonet) writes:
  9.  
  10.  >How about changing the memory model to one that uses far pointers by
  11.  >default?  This should make the string functions fall into line.  However,
  12.  >it shouldn't be too difficult to write your own function that takes two
  13.  >far pointers.
  14.  
  15.   Quite true. For example, from SNIPPETS:
  16.  
  17. /*
  18. **  FMEMOPS.C - Emulate MSC's far memory functions in BC++ & ZTC++
  19. **
  20. **  Original Copyright 1988-1992 by Bob Stout as part of
  21. **  the MicroFirm Function Library (MFL)
  22. **
  23. **  This subset version is hereby donated to the public domain.
  24. */
  25.  
  26. #include <stdlib.h>
  27. #include <string.h>
  28. #include <dos.h>
  29.  
  30. #if defined(__TURBOC__) || defined(__ZTC__)
  31.  
  32. #ifdef __TURBOC__
  33.  #define FAR far
  34. #else
  35.  #define FAR _far
  36. #endif
  37.  
  38. typedef unsigned char FAR *FarBytePtr;
  39.  
  40. void FAR * _fmemcpy(void FAR *dest, void FAR *src, size_t count)
  41. {
  42.       movedata(FP_SEG(src), FP_OFF(src), FP_SEG(dest), FP_OFF(dest), count);
  43.       return dest;
  44. }
  45.  
  46. void FAR * _fmemmove(void FAR *dest, void FAR *src, size_t count)
  47. {
  48.       void FAR *target =  dest;
  49.       FarBytePtr to = (FarBytePtr)dest, from = (FarBytePtr)src;
  50.  
  51.       if (src >= dest)
  52.             _fmemcpy(dest, src, count);
  53.       else  for (to += count, from += count; count; --count)
  54.                   *--to = *--from;
  55.       return target;
  56. }
  57.  
  58. void FAR * _fmemset(void FAR *dest, int ch, size_t count)
  59. {
  60.       void FAR *target =  dest;
  61.       FarBytePtr to = (FarBytePtr)dest;
  62.  
  63.       for ( ; count; --count)
  64.             *to++ = (unsigned char) ch;
  65.       return target;
  66. }
  67.  
  68. #endif
  69.  
  70.  
  71. --- QM v1.00
  72.  * Origin: MicroFirm : Down to the C in chips (1:106/2000.6)
  73. SEEN-BY: 1/211 11/2 4 13/13 101/1 108/89 109/25 110/69 114/5 123/19 124/1
  74. SEEN-BY: 153/752 154/40 77 157/2 159/100 125 575 950 203/23 209/209 261/1023
  75. SEEN-BY: 280/1 390/1 396/1 5 15 2270/1 2440/5 3603/20
  76.