Path: utzoo!utgpu!watserv1!watmath!att!occrsh!uokmax!apple!snorkelwacker!bloom-beacon!eru!luth!sunic!mcsun!hp4nl!kunivv1!atcmpe!ronald From: ronald@atcmp.nl (Ronald Pikkert) Newsgroups: comp.lang.c Subject: Re: B-Trees in C Data Structures -help- Message-ID: <611@atcmpe.atcmp.nl> Date: 3 Jun 90 12:28:51 GMT References: <8790001@hpislx.HP.COM> Organization: AT Computing, Nijmegen, The Netherlands Lines: 27 From article <8790001@hpislx.HP.COM>, by notes@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@atcmp.nl @ AT Computing b.v. Tel: 080 - 566880 Toernooiveld 6525 ED Nijmegen