summaryrefslogtreecommitdiffstats
path: root/src/util/db2/hash/page.h.patch
blob: 4a0311fea38695c62ac18c67852104c15b217c5e (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
*** /tmp/,RCSt1a21720	Wed Apr  3 11:49:55 1996
--- page.h	Wed Apr  3 08:42:25 1996
***************
*** 158,163
  
  #define PAIRFITS(P,K,D)	((PAIRSIZE((K),(D))) <= FREESPACE((P)))
  #define BIGPAIRFITS(P)	((FREESPACE((P)) >= PAIR_OVERHEAD))
  #define FREESPACE(P) \
  	((OFFSET((P)) - PAGE_OVERHEAD - (NUM_ENT((P)) * PAIR_OVERHEAD)))
  

--- 158,169 -----
  
  #define PAIRFITS(P,K,D)	((PAIRSIZE((K),(D))) <= FREESPACE((P)))
  #define BIGPAIRFITS(P)	((FREESPACE((P)) >= PAIR_OVERHEAD))
+ /*
+  * Since these are all unsigned, we need to guarantee that we never go
+  * negative.  Offset values are 0-based and overheads are one based (i.e.
+  * one byte of overhead is 1, not 0), so we need to convert OFFSETs to
+  * 1-based counting before subtraction.
+  */
  #define FREESPACE(P) \
  	((OFFSET((P)) + 1 - PAGE_OVERHEAD - (NUM_ENT((P)) * PAIR_OVERHEAD)))
  
***************
*** 159,165
  #define PAIRFITS(P,K,D)	((PAIRSIZE((K),(D))) <= FREESPACE((P)))
  #define BIGPAIRFITS(P)	((FREESPACE((P)) >= PAIR_OVERHEAD))
  #define FREESPACE(P) \
! 	((OFFSET((P)) - PAGE_OVERHEAD - (NUM_ENT((P)) * PAIR_OVERHEAD)))
  
  /* 
   * Overhead on header pages is just one word -- the length of the

--- 165,171 -----
   * 1-based counting before subtraction.
   */
  #define FREESPACE(P) \
! 	((OFFSET((P)) + 1 - PAGE_OVERHEAD - (NUM_ENT((P)) * PAIR_OVERHEAD)))
  
  /* 
   * Overhead on header pages is just one word -- the length of the