diff options
-rw-r--r-- | src/H5Oalloc.c | 5 | ||||
-rw-r--r-- | src/H5Ocache.c | 26 | ||||
-rw-r--r-- | src/H5Opkg.h | 2 | ||||
-rw-r--r-- | test/stab.c | 8 | ||||
-rw-r--r-- | tools/testfiles/h5mkgrp_nested_latest.ls | 4 | ||||
-rw-r--r-- | tools/testfiles/h5mkgrp_nested_mult_latest.ls | 8 | ||||
-rw-r--r-- | tools/testfiles/h5mkgrp_several_latest.ls | 4 | ||||
-rw-r--r-- | tools/testfiles/h5mkgrp_single_latest.ls | 2 |
8 files changed, 31 insertions, 28 deletions
diff --git a/src/H5Oalloc.c b/src/H5Oalloc.c index 555c7b0..957de77 100644 --- a/src/H5Oalloc.c +++ b/src/H5Oalloc.c @@ -64,7 +64,6 @@ static herr_t H5O_eliminate_gap(H5O_t *oh, H5O_mesg_t *mesg, uint8_t *new_gap_loc, size_t new_gap_size); static herr_t H5O_alloc_null(H5O_t *oh, unsigned null_idx, const H5O_msg_class_t *new_type, void *new_native, size_t new_size); -static herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); static htri_t H5O_alloc_extend_chunk(H5F_t *f, H5O_t *oh, unsigned chunkno, size_t size, unsigned * msg_idx); static unsigned H5O_alloc_new_chunk(H5F_t *f, hid_t dxpl_id, H5O_t *oh, @@ -395,7 +394,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc) { size_t old_alloc; /* Old number of messages allocated */ @@ -410,7 +409,7 @@ H5O_alloc_msgs(H5O_t *oh, size_t min_alloc) /* Initialize number of messages information */ old_alloc = oh->alloc_nmesgs; - na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); + na = oh->alloc_nmesgs + MAX(oh->alloc_nmesgs, min_alloc); /* At least double */ /* Attempt to allocate more memory */ if(NULL == (new_mesg = H5FL_SEQ_REALLOC(H5O_mesg_t, oh->mesg, na))) diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 786d1d3..706497f 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -280,6 +280,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, oh->flags = *p++; if(oh->flags & ~H5O_HDR_ALL_FLAGS) HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL, "unknown object header status flag(s)") + + /* Number of messages (to allocate initially) */ + nmesgs = 1; } /* end if */ else { /* Version */ @@ -292,10 +295,10 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, /* Reserved */ p++; - } /* end else */ - /* Number of messages */ - UINT16DECODE(p, nmesgs); + /* Number of messages */ + UINT16DECODE(p, nmesgs); + } /* end else */ /* Link count */ UINT32DECODE(p, oh->nlink); @@ -496,9 +499,12 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, merged_null_msgs++; } /* end if */ else { - /* New message */ - if(oh->nmesgs >= nmesgs) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too many messages") + /* Check if we need to extend message table to hold the new message */ + if(oh->nmesgs >= oh->alloc_nmesgs) + if(H5O_alloc_msgs(oh, (size_t)1) < 0) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate more space for messages") + + /* Record information about message */ mesgno = oh->nmesgs++; oh->mesg[mesgno].type = H5O_msg_class_g[id]; oh->mesg[mesgno].dirty = FALSE; @@ -574,8 +580,9 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, oh->cache_info.is_dirty = TRUE; /* Sanity check for the correct # of messages in object header */ - if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages") + if(oh->version == H5O_VERSION_1) + if((oh->nmesgs + skipped_msgs + merged_null_msgs) != nmesgs) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages") #ifdef H5O_DEBUG H5O_assert(oh); @@ -652,9 +659,6 @@ H5O_assert(oh); /* Flags */ *p++ = oh->flags; - /* Number of messages */ - UINT16ENCODE(p, oh->nmesgs); - /* Link count */ UINT32ENCODE(p, oh->nlink); diff --git a/src/H5Opkg.h b/src/H5Opkg.h index bd92478..65d4914 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -103,7 +103,6 @@ (H5O_SIZEOF_MAGIC + /*magic number */ \ 1 + /*version number */ \ 1 + /*flags */ \ - 2 + /*number of messages */ \ 4 + /*reference count */ \ (((O)->flags & H5O_HDR_STORE_TIMES) ? ( \ 4 + /*access time */ \ @@ -477,6 +476,7 @@ H5_DLL herr_t H5O_msg_iterate_real(H5F_t *f, H5O_t *oh, const H5O_msg_class_t *t const H5O_mesg_operator_t *op, void *op_data, hid_t dxpl_id); /* Object header allocation routines */ +H5_DLL herr_t H5O_alloc_msgs(H5O_t *oh, size_t min_alloc); H5_DLL unsigned H5O_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, const H5O_msg_class_t *type, const void *mesg); H5_DLL herr_t H5O_condense_header(H5F_t *f, H5O_t *oh, hid_t dxpl_id); diff --git a/test/stab.c b/test/stab.c index 4f61aa5..aea93c6 100644 --- a/test/stab.c +++ b/test/stab.c @@ -427,9 +427,9 @@ lifecycle(hid_t fapl) /* Check that the object header is only one chunk and the space has been allocated correctly */ if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR #ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 208) TEST_ERROR + if(obj_stat.ohdr.size != 206) TEST_ERROR #else /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.size != 188) TEST_ERROR + if(obj_stat.ohdr.size != 186) TEST_ERROR #endif /* H5_HAVE_LARGE_HSIZET */ if(obj_stat.ohdr.free != 0) TEST_ERROR if(obj_stat.ohdr.nmesgs != 6) TEST_ERROR @@ -453,9 +453,9 @@ lifecycle(hid_t fapl) /* Check that the object header is still one chunk and the space has been allocated correctly */ if(H5Gget_objinfo(gid, ".", FALSE, &obj_stat) < 0) TEST_ERROR #ifdef H5_HAVE_LARGE_HSIZET - if(obj_stat.ohdr.size != 208) TEST_ERROR + if(obj_stat.ohdr.size != 206) TEST_ERROR #else /* H5_HAVE_LARGE_HSIZET */ - if(obj_stat.ohdr.size != 188) TEST_ERROR + if(obj_stat.ohdr.size != 186) TEST_ERROR #endif /* H5_HAVE_LARGE_HSIZET */ if(obj_stat.ohdr.free != 112) TEST_ERROR if(obj_stat.ohdr.nmesgs != 3) TEST_ERROR diff --git a/tools/testfiles/h5mkgrp_nested_latest.ls b/tools/testfiles/h5mkgrp_nested_latest.ls index d305312..229a72d 100644 --- a/tools/testfiles/h5mkgrp_nested_latest.ls +++ b/tools/testfiles/h5mkgrp_nested_latest.ls @@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_latest.h5' ############################# Opened "../testfiles/h5mkgrp_nested_latest.h5" with sec2 driver. /one Group - Location: 1:464 + Location: 1:460 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /one/two Group - Location: 1:256 + Location: 1:254 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_nested_mult_latest.ls b/tools/testfiles/h5mkgrp_nested_mult_latest.ls index 9d3a6c0..1ab0757 100644 --- a/tools/testfiles/h5mkgrp_nested_mult_latest.ls +++ b/tools/testfiles/h5mkgrp_nested_mult_latest.ls @@ -3,18 +3,18 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_nested_mult_latest.h5' ############################# Opened "../testfiles/h5mkgrp_nested_mult_latest.h5" with sec2 driver. /one Group - Location: 1:464 + Location: 1:460 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /one/two Group - Location: 1:256 + Location: 1:254 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /three Group - Location: 1:880 + Location: 1:872 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /three/four Group - Location: 1:672 + Location: 1:666 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_several_latest.ls b/tools/testfiles/h5mkgrp_several_latest.ls index 13798cf..a20424d 100644 --- a/tools/testfiles/h5mkgrp_several_latest.ls +++ b/tools/testfiles/h5mkgrp_several_latest.ls @@ -3,10 +3,10 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_several_latest.h5' ############################# Opened "../testfiles/h5mkgrp_several_latest.h5" with sec2 driver. /one Group - Location: 1:256 + Location: 1:254 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX /two Group - Location: 1:464 + Location: 1:460 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX diff --git a/tools/testfiles/h5mkgrp_single_latest.ls b/tools/testfiles/h5mkgrp_single_latest.ls index dd3c95a..d4e8f60 100644 --- a/tools/testfiles/h5mkgrp_single_latest.ls +++ b/tools/testfiles/h5mkgrp_single_latest.ls @@ -3,6 +3,6 @@ Expected output for 'h5ls ../testfiles/h5mkgrp_single_latest.h5' ############################# Opened "../testfiles/h5mkgrp_single_latest.h5" with sec2 driver. /latest Group - Location: 1:256 + Location: 1:254 Links: 1 Modified: XXXX-XX-XX XX:XX:XX XXX |