1 /* 2 swobject - SW object allocation and deallocation 3 4 Copyright (C) 1984-2003 David L. Clark. 5 This program is free software; you can redistribute it and/or modify it under 6 the terms of the GNU General Public License as published by the Free Software 7 Foundation; either version 2 of the License, or (at your option) any later 8 version. This program is distributed in the hope that it will be useful, 9 but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 10 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 11 more details. You should have received a copy of the GNU General Public 12 License along with this program; if not, write to the Free Software Foundation, 13 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 14 15 Author: Dave Clark 16 17 Modification History: 18 84-02-07 Development 19 84-06-12 PCjr Speed-up 20 84-10-31 Atari 21 87-03-09 Microsoft compiler. 22 2003-01-27 GNU General Public License 23 */ 24 #include "sw.h" 25 26 27 28 extern OBJECTS *nobjects; /* Objects list. */ 29 extern OBJECTS *objbot, *objtop, /* Top and bottom of object list */ 30 *objfree, /* Free list */ 31 *deltop, *delbot; /* Newly deallocated objects */ 32 extern OBJECTS *objsmax; /* Maximum allocated object */ 33 34 35 36 OBJECTS *allocobj() 37 { 38 register OBJECTS *ob; 39 40 if ( !objfree ) 41 return( NULL ); 42 43 ob = objfree; 44 objfree = ob->ob_next; 45 46 ob->ob_next = NULL; 47 ob->ob_prev = objbot; 48 49 if ( objbot ) 50 objbot->ob_next = ob; 51 else 52 objtop = ob; 53 54 ob->ob_sound = NULL; 55 ob->ob_drwflg = ob->ob_delflg = 0; 56 if ( ob > objsmax ) 57 objsmax = ob; 58 return( objbot = ob ); 59 } 60 61 62 63 deallobj( obp ) 64 OBJECTS *obp; 65 { 66 register OBJECTS *ob, *obb; 67 68 ob =obp; 69 if ( obb = ob->ob_prev ) 70 obb->ob_next = ob->ob_next; 71 else 72 objtop = ob->ob_next; 73 74 if ( obb = ob->ob_next ) 75 obb->ob_prev = ob->ob_prev; 76 else 77 objbot = ob->ob_prev; 78 79 ob->ob_next = 0; 80 if ( delbot ) 81 delbot->ob_next = ob; 82 else 83 deltop = ob; 84 85 delbot = ob; 86 87 88 } 89 ÿ