ReactOS  0.4.15-dev-1377-ga59cecd
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 }
#define InsertTailList(ListHead, Entry)
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: typedefs.h:119
_IRQL_requires_same_ _In_ CLONG ByteSize
Definition: rtltypes.h:393
base of all file and directory entries
Definition: entries.h:82
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14

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 }
signed char * PCHAR
Definition: retypes.h:7
Definition: ehthrow.cxx:53
Definition: ehthrow.cxx:92
#define A(row, col)
_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:426
#define PCHAR
Definition: match.c:90
#define B(row, col)
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 }
struct _LIST_ENTRY * PLIST_ENTRY
signed char * PCHAR
Definition: retypes.h:7
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
Definition: bufpool.h:45
Definition: typedefs.h:119
#define LIST_ENTRY(type)
Definition: queue.h:175
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by RtlSplayTreeTest().

◆ 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  }
67  for (Ch = (PCHAR)RtlEnumerateGenericTable(&Table, TRUE), i = 0;
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 }
signed char * PCHAR
Definition: retypes.h:7
ASMGENDATA Table[]
Definition: genincdata.c:61
NTSYSAPI ULONG NTAPI RtlNumberGenericTableElements(_In_ PRTL_GENERIC_TABLE Table)
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlEnumerateGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ BOOLEAN Restart)
#define Ch(x, y, z)
Definition: sha2.c:141
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
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
#define FALSE
Definition: types.h:117
static RTL_GENERIC_COMPARE_RESULTS NTAPI CompareCharTable(PRTL_GENERIC_TABLE Table, PVOID A, PVOID B)
Definition: RtlSplayTree.c:17
static VOID NTAPI FreeRoutine(PRTL_GENERIC_TABLE Table, PVOID Buffer)
Definition: RtlSplayTree.c:35
unsigned char BOOLEAN
#define PCHAR
Definition: match.c:90
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlLookupElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
_Must_inspect_result_ NTSYSAPI PVOID NTAPI RtlGetElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ ULONG I)
static VOID del(LPHIST_ENTRY item)
Definition: history.c:199
NTSYSAPI BOOLEAN NTAPI RtlDeleteElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_ PVOID Buffer)
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 ok(value,...)
Definition: atltest.h:57
#define NULL
Definition: types.h:112
char * strchr(const char *String, int ch)
Definition: utclib.c:501
static PVOID NTAPI AllocRoutine(PRTL_GENERIC_TABLE Table, CLONG ByteSize)
Definition: RtlSplayTree.c:26
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI PVOID NTAPI RtlInsertElementGenericTable(_In_ PRTL_GENERIC_TABLE Table, _In_reads_bytes_(BufferSize) PVOID Buffer, _In_ CLONG BufferSize, _Out_opt_ PBOOLEAN NewElement)
char * Text
Definition: combotst.c:136
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14

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
static LIST_ENTRY Allocations
Definition: RtlSplayTree.c:14

Variable Documentation

◆ Allocations

LIST_ENTRY Allocations
static

Definition at line 14 of file RtlSplayTree.c.

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