Making dflat32 a dll. Its a little broken ATM.
[reactos.git] / rosapps / lib / dflat32 / dfalloc.c
1 /* ---------- dfalloc.c ----------
2 * This seems simple enough, if a AllocationError occors
3 * then try to handle it in a somewhat clean fashion.
4 *
5 * Dont ask I didnt write it. - sedwards
6 */
7
8 /* #define WIN32_LEAN_AND_MEAN Removed for ROS */
9
10 #include <windows.h>
11
12 #include <dflat32/dflat.h>
13
14 static void AllocationError(void)
15 {
16 static BOOL OnceIn = FALSE;
17 extern jmp_buf AllocError;
18 extern BOOL AllocTesting;
19 static char *ErrMsg[] = {
20 "ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿",
21 "³ Out of Memory! ³",
22 "RÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄU"
23 };
24 int x, y;
25 CHAR_INFO savbuf[54];
26 DFRECT rc = {30,11,47,13};
27 INPUT_RECORD ir;
28
29 if (!OnceIn)
30 {
31 OnceIn = TRUE;
32 /* ------ close all windows ------ */
33 DfSendMessage(ApplicationWindow, CLOSE_WINDOW, 0, 0);
34 GetVideo(rc, savbuf);
35 for (x = 0; x < 18; x++)
36 {
37 for (y = 0; y < 3; y++)
38 {
39 int c = (255 & (*(*(ErrMsg+y)+x))) | 0x7000;
40 PutVideoChar(x+rc.lf, y+rc.tp, c);
41 }
42 }
43 GetKey(&ir);
44 StoreVideo(rc, savbuf);
45 if (AllocTesting)
46 longjmp(AllocError, 1);
47 }
48 }
49
50 void *DFcalloc(size_t nitems, size_t size)
51 {
52 void *rtn = calloc(nitems, size);
53 if (size && rtn == NULL)
54 AllocationError();
55 return rtn;
56 }
57
58 void *DFmalloc(size_t size)
59 {
60 void *rtn = malloc(size);
61 if (size && rtn == NULL)
62 AllocationError();
63 return rtn;
64 }
65
66 void *DFrealloc(void *block, size_t size)
67 {
68 void *rtn;
69
70 rtn = realloc(block, size);
71 if (size && rtn == NULL)
72 AllocationError();
73 return rtn;
74 }
75
76 /* EOF */