summaryrefslogtreecommitdiffstats
path: root/testbuddy.c
blob: 8454880aa5ae8dae43ba8cc712465dd5e61e920d (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/* ----------------------------------------------------------------------- *
 *   
 *   Copyright 2001-2008 H. Peter Anvin - All Rights Reserved
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, Inc., 675 Mass Ave, Cambridge MA 02139,
 *   USA; either version 2 of the License, or (at your option) any later
 *   version; incorporated herein by reference.
 *
 * ----------------------------------------------------------------------- */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "lpsm.h"

static int testsizes[] = {
  265299,
  336285,
  53234,
  44195236,
  23108,
  360124,
  796226,
  1311075,
  7330,
  597660,
  6006,
  83645,
  4324,
  2820112,
  5911,
  461569,
  1163094,
  247678,
  18184,
  48348,
  2901068,
  52441197,
  4541251,
  2353734,
  384583,
  1421658,
  326213,
  7422104,
  13100,
  21201063,
  1159271,
  848463,
  106239,
  15066610,
  558764,
  599357,
  80851,
  6630,
  11709,
  144683,
  967341,
  17170,
  2954603,
  1021175,
  11821390,
  4263889,
  7024,
  204882,
  15737,
  31181,
  2418369,
  11145790,
  24366,
  163651,
  390920,
  2287775,
  56800676,
  31133580,
  253023,
  11087,
  9835735,
  4371,
  2296700,
  15571,
};

int main(int argc, char *argv[])
{
  void *areas[64];
  int i;

  unlink("buddy.dat");
  unlink("buddy.log");

  if ( !lpsm_init("buddy.dat", "buddy.log") ) {
    fprintf(stderr, "%s: lpsm_arena_init() failed\n", argv[0]);
    return 1;
  }

  lpsm_checkpoint(0.0, PSMSYNC_WAIT);

  for ( i = 0 ; i < 64 ; i++ ) {
    areas[i] = lpsm_malloc(testsizes[i]);
    printf("Alloc: %8d (0x%08x) bytes at %p\n",
	   testsizes[i], testsizes[i], areas[i]);
  }

  lpsm_checkpoint(0.0, PSMSYNC_SYNC);

  return 0;
}