ReactOS 0.4.15-dev-7842-g558ab78
RtlSplayTree.c File Reference
#include <kmt_test.h>
#include <debug.h>
Include dependency graph for RtlSplayTree.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define KMT_EMULATE_KERNEL
 
#define NDEBUG
 

Functions

static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable (PRTL_GENERIC_TABLE Table, PVOID A, PVOID B)
 
static PVOID NTAPI AllocRoutine (PRTL_GENERIC_TABLE Table, CLONG ByteSize)
 
static VOID NTAPI FreeRoutine (PRTL_GENERIC_TABLE Table, PVOID Buffer)
 
static void RtlSplayTreeTest ()
 
 START_TEST (RtlSplayTree)
 

Variables

static LIST_ENTRY Allocations
 

Macro Definition Documentation

◆ KMT_EMULATE_KERNEL

#define KMT_EMULATE_KERNEL

Definition at line 8 of file RtlSplayTree.c.

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file RtlSplayTree.c.

Function Documentation

◆ AllocRoutine()

static PVOID NTAPI AllocRoutine ( PRTL_GENERIC_TABLE  Table,
CLONG  ByteSize 
)
static

Definition at line 26 of file RtlSplayTree.c.

27{
29 (NonPagedPool, sizeof(LIST_ENTRY) + ByteSize);
31 return &Entry[1];
32}
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14
#define InsertTailList(ListHead, Entry)
#define NonPagedPool
Definition: env_spec_w32.h:307
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
base of all file and directory entries
Definition: entries.h:83
Definition: typedefs.h:120
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:399

Referenced by RtlSplayTreeTest().

◆ CompareCharTable()

static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable ( PRTL_GENERIC_TABLE  Table,
PVOID  A,
PVOID  B 
)
static

Definition at line 17 of file RtlSplayTree.c.

18{
20 (*((PCHAR)A) > *((PCHAR)B)) ? GenericGreaterThan :
22 return Result;
23}
Definition: ehthrow.cxx:93
Definition: ehthrow.cxx:54
#define A(row, col)
#define B(row, col)
#define PCHAR
Definition: match.c:90
char * PCHAR
Definition: typedefs.h:51
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
@ GenericLessThan
Definition: rtltypes.h:376
@ GenericEqual
Definition: rtltypes.h:378
@ GenericGreaterThan
Definition: rtltypes.h:377
enum _RTL_GENERIC_COMPARE_RESULTS RTL_GENERIC_COMPARE_RESULTS

Referenced by RtlSplayTreeTest().

◆ FreeRoutine()

static VOID NTAPI FreeRoutine ( PRTL_GENERIC_TABLE  Table,
PVOID  Buffer 
)
static

Definition at line 35 of file RtlSplayTree.c.

36{
40}
Definition: bufpool.h:45
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define LIST_ENTRY(type)
Definition: queue.h:175
struct _LIST_ENTRY * PLIST_ENTRY

◆ RtlSplayTreeTest()

static void RtlSplayTreeTest ( )
static

Definition at line 42 of file RtlSplayTree.c.

43{
44 ULONG i, del;
45 PCHAR Ch;
46 CHAR Text[] = "the quick_brown!fOx-jUmp3d/0vER+THe^lazy.D@g";
47 CHAR NewE[] = "11111111111111111111111111111111110111111111";
50 (&Table,
54 NULL);
55 for (i = 0; Text[i]; i++) {
56 BOOLEAN WasNew;
58 (&Table,
59 &Text[i],
60 sizeof(Text[i]),
61 &WasNew);
62 ok(Ch && *Ch == Text[i], "Copy character into node\n");
63 ok(WasNew == (NewE[i] == '1'),
64 "Character newness didn't match for char %u: '%c'\n",
65 i, Text[i]);
66 }
68 Ch;
70 ok(strchr(Text, *Ch) != NULL, "Nonexistent character\n");
71 }
72 ok(RtlNumberGenericTableElements(&Table) == strlen(Text) - 1, "Not the right number of elements\n");
73 ok(RtlLookupElementGenericTable(&Table, "q") != NULL, "Could not lookup q\n");
74 ok(!RtlLookupElementGenericTable(&Table, "#"), "Found a character that shouldn't appear\n");
75 ok(strlen(Text) == i + 1, "Didn't enumerate enough characters\n");
76 del = 0;
77 for (i = 0; Text[i]; i++) {
78 if (NewE[i] == '1') {
79 BOOLEAN WasDeleted;
80 WasDeleted = RtlDeleteElementGenericTable(&Table, &Text[i]);
81 del += WasDeleted;
82 }
83 }
84 ok(!RtlNumberGenericTableElements(&Table), "Not zero elements\n");
85 ok(!RtlGetElementGenericTable(&Table, 0), "Elements left when we removed them all\n");
86 ok(strlen(Text) == del + 1, "Deleted too many times\n");
87 ok(IsListEmpty(&Allocations), "Didn't free all memory\n");
88}
unsigned char BOOLEAN
static PVOID NTAPI AllocRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
Definition: RtlSplayTree.c:26
static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable(PRTL_GENERIC_TABLE Table, PVOID A, PVOID B)
Definition: RtlSplayTree.c:17
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strchr(const char *String, int ch)
Definition: utclib.c:501
#define ok(value,...)
Definition: atltest.h:57
static VOID del(LPHIST_ENTRY item)
Definition: history.c:199
char * Text
Definition: combotst.c:136
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
VOID NTAPI RtlInitializeGenericTable(IN PRTL_GENERIC_TABLE Table, IN PRTL_GENERIC_COMPARE_ROUTINE CompareRoutine, IN PRTL_GENERIC_ALLOCATE_ROUTINE AllocateRoutine, IN PRTL_GENERIC_FREE_ROUTINE FreeRoutine, IN PVOID TableContext)
Definition: generictable.c:100
ASMGENDATA Table[]
Definition: genincdata.c:61
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define Ch(x, y, z)
Definition: sha2.c:141
uint32_t ULONG
Definition: typedefs.h:59
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_reads_bytes_(BufferSize) PVOID Buffer, _In_ CLONG BufferSize, _Out_opt_ PBOOLEAN NewElement)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ BOOLEAN Restart)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ ULONG I)
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(_In_ PRTL_GENERIC_TABLE Table)
_In_ PRTL_GENERIC_COMPARE_ROUTINE _In_ PRTL_GENERIC_ALLOCATE_ROUTINE _In_ PRTL_GENERIC_FREE_ROUTINE FreeRoutine
Definition: rtlfuncs.h:1090
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
char CHAR
Definition: xmlstorage.h:175

Referenced by START_TEST().

◆ START_TEST()

START_TEST ( RtlSplayTree  )

Definition at line 90 of file RtlSplayTree.c.

91{
94}
static void RtlSplayTreeTest()
Definition: RtlSplayTree.c:42
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944

Variable Documentation

◆ Allocations

LIST_ENTRY Allocations
static

Definition at line 14 of file RtlSplayTree.c.

Referenced by AllocRoutine(), RtlSplayTreeTest(), and START_TEST().