2015-02-01 13:33:06 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
2006-09-25 23:26:08 +00:00
|
|
|
* 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
|
|
|
|
*/
|
2012-09-19 12:20:39 +00:00
|
|
|
SIZE_T
|
|
|
|
NTAPI
|
2006-09-25 23:26:08 +00:00
|
|
|
RtlCompareMemory(IN const VOID *Source1,
|
|
|
|
IN const VOID *Source2,
|
|
|
|
IN SIZE_T Length)
|
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
SIZE_T i;
|
|
|
|
for (i = 0; (i < Length) && (((PUCHAR)Source1)[i] == ((PUCHAR)Source2)[i]); i++)
|
|
|
|
;
|
|
|
|
|
|
|
|
return i;
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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
|
2012-09-19 12:20:39 +00:00
|
|
|
*
|
|
|
|
* @implemented
|
2006-09-25 23:26:08 +00:00
|
|
|
*/
|
2012-09-19 12:20:39 +00:00
|
|
|
SIZE_T
|
|
|
|
NTAPI
|
|
|
|
RtlCompareMemoryUlong(IN PVOID Source,
|
|
|
|
IN SIZE_T Length,
|
|
|
|
IN ULONG Value)
|
2006-09-25 23:26:08 +00:00
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
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);
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef RtlFillMemory
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-09-19 12:20:39 +00:00
|
|
|
RtlFillMemory(PVOID Destination,
|
|
|
|
SIZE_T Length,
|
|
|
|
UCHAR Fill)
|
2006-09-25 23:26:08 +00:00
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
memset(Destination, Fill, Length);
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-09-19 12:20:39 +00:00
|
|
|
RtlFillMemoryUlong(PVOID Destination,
|
|
|
|
SIZE_T Length,
|
|
|
|
ULONG Fill)
|
2006-09-25 23:26:08 +00:00
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
PULONG Dest = Destination;
|
|
|
|
SIZE_T Count = Length / sizeof(ULONG);
|
|
|
|
|
|
|
|
while (Count > 0)
|
|
|
|
{
|
|
|
|
*Dest = Fill;
|
|
|
|
Dest++;
|
|
|
|
Count--;
|
|
|
|
}
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
2013-05-05 09:02:36 +00:00
|
|
|
#ifdef _WIN64
|
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
RtlFillMemoryUlonglong(
|
|
|
|
PVOID Destination,
|
|
|
|
SIZE_T Length,
|
|
|
|
ULONGLONG Fill)
|
|
|
|
{
|
|
|
|
PULONGLONG Dest = Destination;
|
|
|
|
SIZE_T Count = Length / sizeof(ULONGLONG);
|
|
|
|
|
|
|
|
while (Count > 0)
|
|
|
|
{
|
|
|
|
*Dest = Fill;
|
|
|
|
Dest++;
|
|
|
|
Count--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2006-09-25 23:26:08 +00:00
|
|
|
|
|
|
|
#undef RtlMoveMemory
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-09-19 12:20:39 +00:00
|
|
|
RtlMoveMemory(PVOID Destination,
|
|
|
|
CONST VOID *Source,
|
|
|
|
SIZE_T Length)
|
2006-09-25 23:26:08 +00:00
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
memmove(Destination, Source, Length);
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef RtlZeroMemory
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
|
|
|
NTAPI
|
2012-09-19 12:20:39 +00:00
|
|
|
RtlZeroMemory(PVOID Destination,
|
|
|
|
SIZE_T Length)
|
2006-09-25 23:26:08 +00:00
|
|
|
{
|
2012-09-19 12:20:39 +00:00
|
|
|
RtlFillMemory(Destination, Length, 0);
|
2006-09-25 23:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|