2193
2193
 
        } /* end if */
2194
2194
 
    } /* end for */
2195
2195
 
2196
2196
 
    /* Check if the chunk is too small, extend if necessary */
2197
2197
 
    total_msg_size = new_size - (size_t)(chunkno == 0 ? H5O_SIZEOF_HDR(oh) : H5O_SIZEOF_CHKHDR_OH(oh));
2198
2198
 
    if(total_msg_size < min_chunk_size) {
2199
2199
 
        HDassert(oh->alloc_nmesgs > oh->nmesgs);
2200
2200
 
        oh->nmesgs++;
2201
2201
 
2202
2202
 
        /* Initialize new null message to make the chunk large enough */
2203
 
-
        oh->mesg[oh->nmesgs].type = H5O_MSG_NULL;
2204
 
-
        oh->mesg[oh->nmesgs].dirty = TRUE;
2205
 
-
        oh->mesg[oh->nmesgs].native = NULL;
2206
 
-
        oh->mesg[oh->nmesgs].raw = old_image + new_size + sizeof_msghdr - sizeof_chksum;
2207
 
-
        oh->mesg[oh->nmesgs].raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size),
 
2203
+
        curr_msg = &oh->mesg[oh->nmesgs - 1];
 
2204
+
        curr_msg->type = H5O_MSG_NULL;
 
2205
+
        curr_msg->dirty = TRUE;
 
2206
+
        curr_msg->native = NULL;
 
2207
+
        curr_msg->raw = old_image + new_size + sizeof_msghdr - sizeof_chksum;
 
2208
+
        curr_msg->raw_size = MAX(H5O_ALIGN_OH(oh, min_chunk_size - total_msg_size),
2208
2209
 
            sizeof_msghdr) - sizeof_msghdr;
2209
 
-
        oh->mesg[oh->nmesgs].chunkno = chunkno;
 
2210
+
        curr_msg->chunkno = chunkno;
2210
2211
 
2211
2212
 
        /* update the new chunk size */
2212
 
-
        new_size += oh->mesg[oh->nmesgs].raw_size + sizeof_msghdr;
 
2213
+
        new_size += curr_msg->raw_size + sizeof_msghdr;
2213
2214
 
    } /* end if */
2214
2215
 
2215
2216
 
    /* Check for changing the chunk #0 data size enough to need adjusting the flags */
2216
2217
 
    if(oh->version > H5O_VERSION_1 && chunkno == 0) {
2217
2218
 
        uint64_t chunk0_newsize = new_size - (size_t)H5O_SIZEOF_HDR(oh);  /* New size of chunk 0's data */
2218
2219
 
        size_t   orig_prfx_size = (size_t)1 << (oh->flags & H5O_HDR_CHUNK0_SIZE); /* Original prefix size */
2219
2220
 
2220
2221
 
        /* Check for moving to a 1-byte size encoding */
2221
2222
 
        if(orig_prfx_size > 1 && chunk0_newsize <= 255) {
2222
2223
 
            less_prfx_size = orig_prfx_size - 1;