summaryrefslogtreecommitdiffstats
path: root/test/theap.c
blob: 41a9cbcc5faea94ffceae7fb7ad141848a6dd61b (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 "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;
   hatom_t	fid;
   hdf5_file_t	*f;
   off_t	heap;
   char		buf[NOBJS+8];
   const char	*s;
   off_t	obj[NOBJS];
   
   MESSAGE (5, print_func("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, 0);
   CHECK_I (heap, "H5H_new");

   /* Add stuff to the heap */
   for (i=0; i<NOBJS; i++) {
      fprintf (stderr, "%d\n", 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]);
      print_func ("object is `%s'\n", s);
   }

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