File: mswmem.c

package info (click to toggle)
xlispstat 3.52.14-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 7,560 kB
  • ctags: 12,676
  • sloc: ansic: 91,357; lisp: 21,759; sh: 1,525; makefile: 521; csh: 1
file content (60 lines) | stat: -rw-r--r-- 1,122 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifdef _Windows

#include <windows.h>
#include <windowsx.h>
#include <mem.h>

extern char *Lmalloc(unsigned long);
extern char *Lrealloc(char *, unsigned long);
extern void Lfree(char *);

char *NewSegment()
{
  HANDLE h;
  h = GlobalAlloc(GMEM_FIXED, 0x010000L);
  return ((h) ? GlobalLock(h) : 0);
}

void FreeSegment(char *s)
{
  GlobalUnlockPtr(s);
  GlobalFree(GlobalPtrHandle(s));
}

char *malloc(unsigned n) { return(Lmalloc(n)); }
char *realloc(char *s, unsigned n) { return(Lrealloc(s, n)); }
void free(char *s) { Lfree(s); }

char *calloc(unsigned n, unsigned m)
{
  char *s;
  long size;
  size = ((long) n) * ((long) m);
  s = Lmalloc(size);
  if (s) memset(s, 0, (size_t) size);
  return(s);
}

#else
extern char *Lmalloc(), *Lrealloc();
extern void Lfree();

extern char *malloc();

char *NewSegment() { return(malloc(0x010000)); }
void FreeSegment(s) char *s; { free(s); }

main()
{
  int i, n;
  char *s;

  n = 10000;
  s = Lmalloc(n);
  for (i = 0; i < n; i++) s[i] = 1;
  s = Lrealloc(s, 2 * n);
  for (i = 0; i < 2 * n; i++) s[i] = 1;
  s = Lrealloc(s, n);
  for (i = 0; i < n; i++) s[i] = 1;
}
#endif