ソースを参照

allocate size infos in page data when < 8 blocks (prevent breaking big 4MB blocks)

Nicolas Cannasse 6 年 前
コミット
1fab9c1181
1 ファイル変更8 行追加2 行削除
  1. 8 2
      src/alloc.c

+ 8 - 2
src/alloc.c

@@ -113,6 +113,8 @@ struct _gc_pheader {
 	int free_blocks;
 	unsigned char *sizes;
 	unsigned char *bmp;
+	int sizes_ref;
+	int sizes_ref2;
 	gc_pheader *next_page;
 #ifdef GC_DEBUG
 	int page_id;
@@ -481,8 +483,12 @@ retry:
 	if( p->max_blocks > GC_PAGE_SIZE )
 		hl_fatal("Too many blocks for this page");
 	if( varsize ) {
-		p->sizes = base + start_pos;
-		start_pos += p->max_blocks;
+		if( p->max_blocks <= 8 )
+			p->sizes = (unsigned char*)&p->sizes_ref;
+		else {
+			p->sizes = base + start_pos;
+			start_pos += p->max_blocks;
+		}
 		MZERO(p->sizes,p->max_blocks);
 	}
 	m = start_pos % block;