| 1 | /* $Id: crt_memory.cpp,v 1.1 2000-11-21 23:48:54 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * The C RunTime DLL
|
|---|
| 5 | *
|
|---|
| 6 | * Implements C run-time functionality as known from UNIX.
|
|---|
| 7 | *
|
|---|
| 8 | * Partialy based on Wine
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright 1996,1998 Marcus Meissner
|
|---|
| 11 | * Copyright 1996 Jukka Iivonen
|
|---|
| 12 | * Copyright 1997 Uwe Bonnes
|
|---|
| 13 | * Copyright 1999-2000 Jens Wiessner
|
|---|
| 14 | *
|
|---|
| 15 | * CRTDLL - memory functions
|
|---|
| 16 | *
|
|---|
| 17 | */
|
|---|
| 18 |
|
|---|
| 19 | #include <odin.h>
|
|---|
| 20 | #include <os2win.h>
|
|---|
| 21 | #include <ctype.h>
|
|---|
| 22 | #include <memory.h>
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 | /*********************************************************************
|
|---|
| 26 | * _memccpy (CRTDLL.230)
|
|---|
| 27 | */
|
|---|
| 28 | void * CDECL CRTDLL__memccpy (void *s1, const void *s2, int c, size_t n)
|
|---|
| 29 | {
|
|---|
| 30 | dprintf2(("CRTDLL: _memccpy\n"));
|
|---|
| 31 | size_t i;
|
|---|
| 32 |
|
|---|
| 33 | for (i = 0; i < n; ++i)
|
|---|
| 34 | {
|
|---|
| 35 | if ((((char *)s1)[i] = ((char *)s2)[i]) == (char)c)
|
|---|
| 36 | return (char *)s1+i+1;
|
|---|
| 37 | }
|
|---|
| 38 | return NULL;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 | /*********************************************************************
|
|---|
| 43 | * _memicmp (CRTDLL.231)
|
|---|
| 44 | */
|
|---|
| 45 | INT CDECL CRTDLL__memicmp(
|
|---|
| 46 | LPCSTR s1, /* [in] first string */
|
|---|
| 47 | LPCSTR s2, /* [in] second string */
|
|---|
| 48 | DWORD len /* [in] length to compare */ )
|
|---|
| 49 | {
|
|---|
| 50 | dprintf2(("CRTDLL: _memicmp(%08xh, %08xh, %08xh)\n",s1,s2,len));
|
|---|
| 51 | int i;
|
|---|
| 52 |
|
|---|
| 53 | for (i=0;i<len;i++) {
|
|---|
| 54 | if (tolower(s1[i])<tolower(s2[i]))
|
|---|
| 55 | return -1;
|
|---|
| 56 | if (tolower(s1[i])>tolower(s2[i]))
|
|---|
| 57 | return 1;
|
|---|
| 58 | }
|
|---|
| 59 | return 0;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 | /*********************************************************************
|
|---|
| 65 | * memchr (CRTDLL.428)
|
|---|
| 66 | */
|
|---|
| 67 | void * CDECL CRTDLL_memchr( const void *s, int c, size_t n )
|
|---|
| 68 | {
|
|---|
| 69 | dprintf2(("CRTDLL: memchr(%08xh, %08xh, %08xh)\n", s, c, n));
|
|---|
| 70 | return memchr( s, c, n );
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | /*********************************************************************
|
|---|
| 75 | * memcmp (CRTDLL.429)
|
|---|
| 76 | */
|
|---|
| 77 | int CDECL CRTDLL_memcmp( const void * c1, const void * c2, size_t n )
|
|---|
| 78 | {
|
|---|
| 79 | dprintf2(("CRTDLL: memcmp(%08xh, %08xh, %08xh)\n", c1, c2, n));
|
|---|
| 80 | return memcmp( c1, c2, n );
|
|---|
| 81 | }
|
|---|
| 82 |
|
|---|
| 83 |
|
|---|
| 84 | /*********************************************************************
|
|---|
| 85 | * memcpy (CRTDLL.430)
|
|---|
| 86 | */
|
|---|
| 87 | void * CDECL CRTDLL_memcpy( void *s1, const void *s2, size_t n )
|
|---|
| 88 | {
|
|---|
| 89 | dprintf2(("CRTDLL: memcpy(%08xh, %08xh, %08xh)\n", s1, s2, n));
|
|---|
| 90 | return memcpy( s1, s2, n );
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | /*********************************************************************
|
|---|
| 95 | * memmove (CRTDLL.431)
|
|---|
| 96 | */
|
|---|
| 97 | VOID CDECL CRTDLL_memmove(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, DWORD Length)
|
|---|
| 98 | {
|
|---|
| 99 | dprintf2(("CRTDLL: memmove"));
|
|---|
| 100 | memmove(Destination, Source, Length);
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | /*********************************************************************
|
|---|
| 105 | * memset (CRTDLL.432)
|
|---|
| 106 | */
|
|---|
| 107 | void * CDECL CRTDLL_memset( void *s, int i, size_t n )
|
|---|
| 108 | {
|
|---|
| 109 | dprintf2(("CRTDLL: memset(%08xh, %08xh, %08xh)\n", s, i, n));
|
|---|
| 110 | return memset( s, i, n );
|
|---|
| 111 | }
|
|---|