Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/rtl/mem.c * PURPOSE: Memory functions * PROGRAMMER: David Welch (welch@mcmail.com) */
/* INCLUDES *****************************************************************/
#include <rtl.h>
#define NDEBUG#include <debug.h>
/* FUNCTIONS *****************************************************************/
/****************************************************************************** * RtlCompareMemory [NTDLL.@] * * Compare one block of memory with another * * PARAMS * Source1 [I] Source block * Source2 [I] Block to compare to Source1 * Length [I] Number of bytes to fill * * RETURNS * The length of the first byte at which Source1 and Source2 differ, or Length * if they are the same. * * @implemented */SIZE_TNTAPIRtlCompareMemory(IN const VOID *Source1, IN const VOID *Source2, IN SIZE_T Length){ SIZE_T i; for (i = 0; (i < Length) && (((PUCHAR)Source1)[i] == ((PUCHAR)Source2)[i]); i++) ;
return i;}
/* * FUNCTION: Compares a block of ULONGs with an ULONG and returns the number of equal bytes * ARGUMENTS: * Source = Block to compare * Length = Number of bytes to compare * Value = Value to compare * RETURNS: Number of equal bytes * * @implemented */SIZE_TNTAPIRtlCompareMemoryUlong(IN PVOID Source, IN SIZE_T Length, IN ULONG Value){ PULONG ptr = (PULONG)Source; ULONG_PTR len = Length / sizeof(ULONG); ULONG_PTR i;
for (i = 0; i < len; i++) { if (*ptr != Value) break;
ptr++; }
return (SIZE_T)((PCHAR)ptr - (PCHAR)Source);}
#undef RtlFillMemory/* * @implemented */VOIDNTAPIRtlFillMemory(PVOID Destination, SIZE_T Length, UCHAR Fill){ memset(Destination, Fill, Length);}
#ifndef _M_AMD64/* * @implemented */VOIDNTAPIRtlFillMemoryUlong(PVOID Destination, SIZE_T Length, ULONG Fill){ PULONG Dest = Destination; SIZE_T Count = Length / sizeof(ULONG);
while (Count > 0) { *Dest = Fill; Dest++; Count--; }}
#ifdef _WIN64VOIDNTAPIRtlFillMemoryUlonglong( PVOID Destination, SIZE_T Length, ULONGLONG Fill){ PULONGLONG Dest = Destination; SIZE_T Count = Length / sizeof(ULONGLONG);
while (Count > 0) { *Dest = Fill; Dest++; Count--; }}#endif // _WIN64#endif // _M_AMD64
#undef RtlMoveMemory/* * @implemented */VOIDNTAPIRtlMoveMemory(PVOID Destination, CONST VOID *Source, SIZE_T Length){ memmove(Destination, Source, Length);}
#undef RtlZeroMemory/* * @implemented */VOIDNTAPIRtlZeroMemory(PVOID Destination, SIZE_T Length){ RtlFillMemory(Destination, Length, 0);}
/* EOF */