1 /*- 2 * listSetCirc.c -- 3 * Change the library's notion of the circularity of a list. 4 * 5 * Copyright (c) 1988 by the Regents of the University of California 6 * 7 * Copyright (c) 1988 by Adam de Boor 8 * 9 * Permission to use, copy, modify, and distribute this 10 * software and its documentation for any purpose and without 11 * fee is hereby granted, provided that the above copyright 12 * notice appears in all copies. The University of California nor 13 * Adam de Boor makes any representations about the suitability of this 14 * software for any purpose. It is provided "as is" without 15 * express or implied warranty. 16 * 17 * 18 */ 19 #ifndef lint 20 static char *rcsid = 21 "$Id: lstSetCirc.c,v 1.3 88/11/17 20:54:04 adam Exp $ SPRITE (Berkeley)"; 22 #endif lint 23 24 #include "lstInt.h" 25 26 /* 27 *------------------------------------------------------------ 28 * Lst_SetCirc -- 29 * change the circularity of a list 30 * 31 * Results: 32 * none 33 * 34 * Side Effects: 35 * The circularity of the list is set appropriately. The head and 36 * tail of the list will be linked or unlinked as necessary 37 *------------------------------------------------------------ 38 */ 39 void 40 Lst_SetCirc (l, circ) 41 Lst l; 42 Boolean circ; 43 { 44 register List list = (List) l; 45 46 /* 47 * if this isn't a change, do nothing. 48 */ 49 if ((list->isCirc && circ) || (!list->isCirc && !circ)) { 50 return; 51 } 52 list->isCirc = circ; 53 54 if (LstIsEmpty (l)) { 55 return; 56 } 57 58 if (circ) { 59 list->firstPtr->prevPtr = list->lastPtr; 60 list->lastPtr->nextPtr = list->firstPtr; 61 } else { 62 list->firstPtr->prevPtr = NilListNode; 63 list->lastPtr->nextPtr = NilListNode; 64 } 65 } 66