Re: Infinite loops

From: Daniel Koepke (dkoepke@CALIFORNIA.COM)
Date: 08/21/97


On Thu, 21 Aug 1997, George wrote:

-+I recommend this construct for every for() loop in CircleMUD:
-+
-+    for (toy = get_buffer_head(); toy; toy = toy->next)
-+      if (toy == toy->next) {
-+        log("SYSERR: BUF: do_buffer: Infinite loop!");
-+        toy->next = NULL;
-+      } else if (!toy->used && toy->size == size &&

I really wouldn't suggest bogging down loops with 'if' constructs.  The
repeated conditionals are inefficient, and it makes the code look worse.
So why bother with it when just causing the MUD to crash with SIGSEGV will
get you a nice "core" file and you can tell where it locked up at.  At
least, from my recollection.  Although, I suppose it might be appropriate
for Macintosh or Windows-based Circles (because those operating systems
don't dump cores; at least, Windows doesn't, and I don't think System
does).


Think on this:
"I hate brussel sprouts." -- illegal in 13 states
"Fuck you, dickhead." -- illegal in 0 states
Just some food for thought (no pun intended; brussel sprouts aren't food).

--
Daniel Koepke -:- dkoepke@california.com -:-  [Shadowlord/Nether]
Think.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST