1 /*************************************************************************** 2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992 3 Copyright 1990 Regents of the University of California. All rights reserved. 4 Authors: 1985 Thomas L. Quarles 5 1993 Stephen R. Whiteley 6 ****************************************************************************/ 7 8 /* 9 * This routine deletes a typed model and its instances from the circuit 10 * and frees the storage used. 11 */ 12 13 #include "spice.h" 14 #include <stdio.h> 15 #include "gendefs.h" 16 #include "util.h" 17 #include "sperror.h" 18 19 20 int GENmDelete(model,modname,modfast)21GENmDelete(model,modname,modfast) 22 23 GENmodel **model; 24 IFuid modname; 25 GENmodel *modfast; 26 { 27 GENinstance *here, *next; 28 GENmodel **oldmod; 29 30 oldmod = model; 31 for ( ; *model; model = &((*model)->GENnextModel)) { 32 if ((*model)->GENmodName == modname || 33 (modfast && *model == modfast)) break; 34 oldmod = model; 35 } 36 if (!*model) return(E_NOMOD); 37 38 /* cut deleted device out of list */ 39 *oldmod = (*model)->GENnextModel; 40 41 for (here = (*model)->GENinstances; here; here = next) { 42 next = here->GENnextInstance; 43 FREE(here); 44 } 45 FREE(*model); 46 return (OK); 47 } 48