summaryrefslogtreecommitdiffstats
path: root/test/theap.c
blob: 1dc38e16489a8f430f8f3c566d6ca293baaf91ed (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
/*-------------------------------------------------------------------------
 * Copyright (C) 1997	National Center for Supercomputing Applications.
 *                      All rights reserved.
 *
 *-------------------------------------------------------------------------
 *
 * Created:		theap.c
 * 			Jul 17 1997
 * 			Robb Matzke <robb@maya.nuance.com>
 *
 * Purpose:		
 *
 * Modifications:	
 *
 *-------------------------------------------------------------------------
 */
#include <testhdf5.h>

#include <H5private.h>
#include <H5ACprivate.h>
#include <H5Fprivate.h>
#include <H5Hprivate.h>

#define NOBJS	40


/*-------------------------------------------------------------------------
 * Function:	test_heap
 *
 * Purpose:	Test name and object heaps.
 *
 * Return:	void
 *
 * Programmer:	Robb Matzke
 *		robb@maya.nuance.com
 *		Jul 17 1997
 *
 * Modifications:
 *
 *-------------------------------------------------------------------------
 */
void
test_heap (void)
{
   int		i, j;
   hid_t	fid;
   H5F_t	*f;
   off_t	heap;
   char		buf[NOBJS+8];
   const char	*s;
   off_t	obj[NOBJS];
   
   MESSAGE (5, ("Testing Heaps\n"));

   /* Create the file */
   fid = H5Fcreate ("theap.h5", H5ACC_OVERWRITE, 0, 0);
   CHECK (fid, FAIL, "H5Fcreate");
   f = H5Aatom_object (fid);
   CHECK (f, NULL, "H5Aatom_object");

   /* Create a new heap */
   heap = H5H_new (f, H5H_LOCAL, 0);
   CHECK_I (heap, "H5H_new");

   /* Add stuff to the heap */
   for (i=0; i<NOBJS; i++) {
      sprintf (buf, "%03d-", i);
      for (j=4; j<i; j++) buf[j] = '0' + j%10;
      if (j>4) buf[j] = '\0';

      obj[i] = H5H_insert (f, heap, strlen(buf)+1, buf);
      CHECK_I (heap, "H5H_insert");
   }

   /* Flush the cache and invalidate everything */
   H5AC_flush (f, NULL, 0, TRUE);

   /* Read the objects back out */
   for (i=0; i<NOBJS; i++) {
      s = H5H_peek (f, heap, obj[i]);
      MESSAGE (8, ("object is `%s'\n", s));
   }

   /* Close the file */
   H5Fclose (fid);
}