source: trunk/src/win32k/test/AllocMem.c@ 10367

Last change on this file since 10367 was 5109, checked in by bird, 25 years ago

initial coding

File size: 1.8 KB
Line 
1/* $Id: AllocMem.c,v 1.1 2001-02-11 15:25:51 bird Exp $
2 *
3 * Program which allocates memory.
4 *
5 * Copyright (c) 2001 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 */
10
11
12
13/*******************************************************************************
14* Defined Constants And Macros *
15*******************************************************************************/
16#define INCL_BASE
17
18
19/*******************************************************************************
20* Header Files *
21*******************************************************************************/
22#include <os2.h>
23
24#ifndef OBJ_ANY
25#define OBJ_ANY 0x400UL
26#endif
27
28#include <string.h>
29#include <stdio.h>
30#include <stdlib.h>
31
32
33
34
35int main(argc, argv)
36int argc;
37char **argv;
38{
39 int argi;
40 PVOID pv;
41 APIRET rc;
42 ULONG cbMem = 1024*1024*20;
43 ULONG flFlags = PAG_READ | PAG_WRITE | PAG_COMMIT;
44
45 for (argi = 1; argi < argc; argi++ )
46 {
47 if (argv[argi][0] == '-')
48 flFlags |= OBJ_ANY;
49 else
50 {
51 char *psz;
52 cbMem = strtol(argv[argi], &psz,
53 argv[argi][0] == '0' && (argv[argi][1] == 'x' || argv[argi][1] == 'X')
54 ? 16 : 10);
55 }
56 }
57
58
59 rc = DosAllocMem(&pv, cbMem, flFlags);
60 printf("DosAllocMem(, 0x%x, 0x%x) -> rc=%d, pv=0x%x\n", cbMem, flFlags, rc, pv);
61 if (!rc)
62 {
63 char *pch;
64 char *pchEnd = (char*)pv + cbMem;
65 printf("Press a key to touch all pages.\n");
66 getc(stdin);
67 for (pch = (char*)pv; pch < pchEnd; pch += 0x1000)
68 *pch = '1';
69 printf("Press a key to exit.\n");
70 getc(stdin);
71 }
72
73 return 0;
74}
Note: See TracBrowser for help on using the repository browser.