Skip to content

Commit

Permalink
manual backport of #2735 (#2742)
Browse files Browse the repository at this point in the history
  • Loading branch information
metzm committed Jan 9, 2023
1 parent 33610c5 commit 1b7d220
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/vector/diglib/spindex_rw.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ int dig_Wr_spidx_head(struct gvfile * fp, struct Plus_head *ptr)
unsigned char buf[6];
long length = 81; /* header length in bytes */
struct RTree *t;
size_t size;

dig_rewind(fp);
dig_set_cur_port(&(ptr->spidx_port));

/* use ptr->off_t_size = 4 if possible */
if (sizeof(off_t) > 4) {
off_t size;

size = 145; /* max header size, see below */
size += ptr->Node_spidx->n_nodes * ptr->Node_spidx->nodesize;
size += ptr->Line_spidx->n_nodes * ptr->Line_spidx->nodesize;
size += ptr->Area_spidx->n_nodes * ptr->Area_spidx->nodesize;
size += ptr->Isle_spidx->n_nodes * ptr->Isle_spidx->nodesize;
size += (off_t)ptr->Node_spidx->n_nodes * ptr->Node_spidx->nodesize;
size += (off_t)ptr->Line_spidx->n_nodes * ptr->Line_spidx->nodesize;
size += (off_t)ptr->Area_spidx->n_nodes * ptr->Area_spidx->nodesize;
size += (off_t)ptr->Isle_spidx->n_nodes * ptr->Isle_spidx->nodesize;

if (size < PORT_INT_MAX)
ptr->spidx_port.off_t_size = 4;
Expand Down

0 comments on commit 1b7d220

Please sign in to comment.