ReactOS 0.4.16-dev-1113-g99ecbf5
rosglue.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: FreeType implementation for ReactOS
4 * PURPOSE: Glue functions between FreeType
5 * FILE: win32ss/drivers/font/ftfd/rosglue.c
6 * PROGRAMMER: Ge van Geldorp (ge@gse.nl)
7 * NOTES:
8 */
9
10#include "ftfd.h"
11
12#define TAG_FREETYPE 'PYTF'
13
14/* print a message */
15void
16FT_Message(const char *format, ...)
17{
18 va_list va;
19
20 va_start(va, format);
21 EngDebugPrint("FreeType: ", (PCHAR)format, va);
22 va_end(va);
23}
24
25/* print a message and exit */
26void
27FT_Panic(const char *format, ...)
28{
29 va_list va;
30
31 va_start(va, format);
32 EngDebugPrint("FreeType: ", (PCHAR)format, va);
33 EngBugCheckEx(0xDEADBEEF, 0, 0, 0, 0);
34 va_end(va);
35}
36
37/*
38 * Memory allocation
39 *
40 * Because of realloc, we need to keep track of the size of the allocated
41 * buffer (need to copy the old contents to the new buffer). So, allocate
42 * extra space for a size_t, store the allocated size in there and return
43 * the address just past it as the allocated buffer.
44 * On win64 we need to align the allocation to 16 bytes, otherwise 8 bytes.
45 */
46typedef struct _MALLOC_HEADER
47{
51
52void *
53malloc(size_t Size)
54{
56
58 if (Header == NULL)
59 {
60 return NULL;
61 }
62
63 Header->Size = Size;
64 Header->Alignment = -1;
65 return (Header + 1);
66}
67
68void *
69realloc(void *Object, size_t Size)
70{
72 PMALLOC_HEADER OldHeader;
73 size_t CopySize;
74
76 if (NewObject == NULL)
77 {
78 return NULL;
79 }
80
81 if (Object == NULL)
82 {
83 return NewObject;
84 }
85
86 OldHeader = (PMALLOC_HEADER)Object - 1;
87 CopySize = min(OldHeader->Size, Size);
88 memcpy(NewObject, Object, CopySize);
89
90 free(Object);
91
92 return NewObject;
93}
94
95void
97{
98 if (Object != NULL)
99 {
101 }
102}
103
104/*
105 * File I/O
106 *
107 * This is easy, we don't want FreeType to do any I/O. So return an
108 * error on each I/O attempt. Note that errno is not being set, it is
109 * not used by FreeType.
110 */
111
112FILE *
113fopen(const char *FileName, const char *Mode)
114{
115 FT_Message("Freetype tries to open file %s\n", FileName);
116 return NULL;
117}
118
119int
120fseek(FILE *Stream, long Offset, int Origin)
121{
122 FT_Message("Doubleplus ungood: freetype shouldn't fseek!\n");
123 return -1;
124}
125
126long
128{
129 FT_Message("Doubleplus ungood: freetype shouldn't ftell!\n");
130 return -1;
131}
132
133size_t
134fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
135{
136 FT_Message("Doubleplus ungood: freetype shouldn't fread!\n");
137 return 0;
138}
139
140int
142{
143 FT_Message("Doubleplus ungood: freetype shouldn't fclose!\n");
144 return EOF;
145}
char * va_list
Definition: acmsvcex.h:78
#define va_end(ap)
Definition: acmsvcex.h:90
#define va_start(ap, A)
Definition: acmsvcex.h:91
Definition: bufpool.h:45
Definition: Header.h:9
#define realloc
Definition: debug_ros.c:6
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
long ftell(FILE *Stream)
Definition: rosglue.c:127
#define TAG_FREETYPE
Definition: rosglue.c:12
struct _MALLOC_HEADER MALLOC_HEADER
void FT_Message(const char *format,...)
Definition: rosglue.c:16
FILE * fopen(const char *FileName, const char *Mode)
Definition: rosglue.c:113
int fseek(FILE *Stream, long Offset, int Origin)
Definition: rosglue.c:120
int fclose(FILE *Stream)
Definition: rosglue.c:141
void FT_Panic(const char *format,...)
Definition: rosglue.c:27
struct _MALLOC_HEADER * PMALLOC_HEADER
size_t fread(void *Buffer, size_t Size, size_t Count, FILE *Stream)
Definition: rosglue.c:134
_In_ ULONG Mode
Definition: hubbusif.h:303
#define EOF
Definition: stdio.h:24
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static IStream Stream
Definition: htmldoc.c:1115
#define min(a, b)
Definition: monoChain.cc:55
int Count
Definition: noreturn.cpp:7
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
#define EngFreeMem
Definition: polytest.cpp:56
void * EngAllocMem(int zero, unsigned long size, int tag=0)
Definition: polytest.cpp:70
SIZE_T Alignment
Definition: rosglue.c:49
SIZE_T Size
Definition: rosglue.c:48
Definition: format.c:58
ULONG_PTR SIZE_T
Definition: typedefs.h:80
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
ENGAPI VOID APIENTRY EngBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR P1, _In_ ULONG_PTR P2, _In_ ULONG_PTR P3, _In_ ULONG_PTR P4)
ENGAPI VOID APIENTRY EngDebugPrint(_In_z_ PCHAR StandardPrefix, _In_z_ PCHAR DebugMessage, _In_ va_list ap)
Definition: debug.c:19
_Inout_opt_ PACCESS_STATE _In_opt_ ACCESS_MASK _In_ ULONG _Out_opt_ PVOID * NewObject
Definition: obfuncs.h:74