for (pp=PartHeadp->pt_forw; pp != PartHeadp;

Developers
Alex Kid
2008-09-30
2013-04-22
  • Alex Kid
    Alex Kid
    2008-09-30

    Hi everybody ,

    Just want to know how "to get out of"  for (pp=PartHeadp->pt_forw; pp != PartHeadp; pp = pp->pt_forw)

    pp= PartHeadp; doesn't work .

    Sorry for my english.

    Thanks

     
    • Sean Morrison
      Sean Morrison
      2008-09-30

      Alex,

      Where'd you get the struct partition from?  Testing for pp != PartHeadp is sufficient on a ray-trace partition hit callback.  If that's not working, you probably have a mistake somewhere else.

      (note you said pp= PartHeadp which is an assignment that will always be true)

      "man librt" or "brlman librt" has an example of a hit callback that iterates over the partitions (although it's old, see raytrace.h for the current callback signature).

      Sean

       
    • If you are trying to exit the for loop early, setting "pp = PartHeadp" inside the loop won't work because the increment part of the for loop will execute before the test.  That means "pp = pp->pt_forw" will be executed before the test "pp != PartHeadp".

      If you don't have nested loops, using "break" should work for you instead of "pp = PartHeadp"