Skip to content

Commit

Permalink
change while() to a for() loop and copydata now works... go figure
Browse files Browse the repository at this point in the history
  • Loading branch information
teuben committed Jan 2, 2025
1 parent 3fe34ea commit cd055d9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/kernel/io/filesecret.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,15 +1224,21 @@ local void copydata(
char *src, *dat = (char *) vdat;
off_t oldpos;

dprintf(0,"COPYDATA: off=%ld len=%ld\n", off, len);

off *= ItemLen(ipt); /* offset bytes from start */
if (ItemDat(ipt) != NULL) { /* data already in core? */
src = (char *) ItemDat(ipt) + off; /* get pointer to source */
len *= ItemLen(ipt); /* number of bytes to copy */
dprintf(0,"COPYDATA2: len=%ld src=0x%x dat=0x%x\n",len, src, dat);
while (--len >= 0) /* loop copying data */
// dprintf(0,"COPYDATA2: len=%ld src=0x%x dat=0x%x\n",len, src, dat);
#if 0
// this while loop will hit through 0, and eventually segfault in the copy
// compiler bug ?
while (--len >= 0) { /* loop copying data */
*dat++ = *src++; /* byte by byte */
}
#else
for (size_t i=0; i<len; i++)
*dat++ = *src++;
#endif
} else { /* time to read data in */
oldpos = ftello(str); /* save current place */
safeseek(str, ItemPos(ipt) + off, 0); /* seek back to data */
Expand Down

0 comments on commit cd055d9

Please sign in to comment.