B-Trees in C Data Structures -help-
Ronald Pikkert
ronald at atcmp.nl
Sun Jun 3 22:28:51 AEST 1990
>From article <8790001 at hpislx.HP.COM>, by notes at hpislx.HP.COM (Notesfiles System):
> I have a B-tree program that works up to the first split but when it needs
> to split again it goes into a recursive loop. I've looked and looked at the
> code and it seems ok logically???Stumped???
>
>
> short getpage()
> {
> long lseek(), addr;
> addr = lseek(btfd, 0L, 2) - 2L;
> return((short) addr / PAGESIZE);
> }
>
Your problem is in the page calculation routine. The addr is first converted
into a short and then divided by PAGESIZE.
Change this line into:
return((short) (addr / PAGESIZE));
Don't worry, it's only a pair of brackets on a lot of code :-)
-
Ronald Pikkert E-mail: ronald at atcmp.nl
@ AT Computing b.v. Tel: 080 - 566880
Toernooiveld
6525 ED Nijmegen
More information about the Comp.lang.c
mailing list