/misc/src/release/graphviz-2.18-1/src/graphviz-2.18/lib/cdt/dtclose.c

Go to the documentation of this file.
00001 /* $Id: dtclose.c,v 1.1.1.1 2004/12/23 04:03:59 ellson Exp $ $Revision: 1.1.1.1 $ */
00002 /* vim:set shiftwidth=4 ts=8: */
00003 
00004 /**********************************************************
00005 *      This software is part of the graphviz package      *
00006 *                http://www.graphviz.org/                 *
00007 *                                                         *
00008 *            Copyright (c) 1994-2004 AT&T Corp.           *
00009 *                and is licensed under the                *
00010 *            Common Public License, Version 1.0           *
00011 *                      by AT&T Corp.                      *
00012 *                                                         *
00013 *        Information and Software Systems Research        *
00014 *              AT&T Research, Florham Park NJ             *
00015 **********************************************************/
00016 
00017 #include        "dthdr.h"
00018 
00019 #ifdef DMALLOC
00020 #include "dmalloc.h"
00021 #endif
00022 
00023 /*      Close a dictionary
00024 **
00025 **      Written by Kiem-Phong Vo (05/25/96)
00026 */
00027 #if __STD_C
00028 int dtclose(reg Dt_t * dt)
00029 #else
00030 int dtclose(dt)
00031 reg Dt_t *dt;
00032 #endif
00033 {
00034     if (dt->nview > 0)          /* can't close if being viewed */
00035         return -1;
00036 
00037     if (dt->view)               /* turn off viewing */
00038         dtview(dt, NIL(Dt_t *));
00039 
00040     /* announce the close event */
00041     if (dt->disc->eventf &&
00042         (*dt->disc->eventf) (dt, DT_CLOSE, NIL(Void_t *), dt->disc) < 0)
00043         return -1;
00044 
00045     /* release all allocated data */
00046     (void) (*(dt->meth->searchf)) (dt, NIL(Void_t *), DT_CLEAR);
00047     if (dtsize(dt) > 0)
00048         return -1;
00049 
00050     if (dt->data->ntab > 0)
00051         (*dt->memoryf) (dt, (Void_t *) dt->data->htab, 0, dt->disc);
00052     (*dt->memoryf) (dt, (Void_t *) dt->data, 0, dt->disc);
00053 
00054     free((Void_t *) dt);
00055 
00056     return 0;
00057 }

Generated on Mon Mar 31 19:03:23 2008 for Graphviz by  doxygen 1.5.1