| 1 |
#include "config.h" |
| 2 |
|
| 3 |
#include <cdt/dthdr.h> |
| 4 |
#include <stdlib.h> |
| 5 |
|
| 6 |
/* Close a dictionary |
| 7 |
** |
| 8 |
** Written by Kiem-Phong Vo (05/25/96) |
| 9 |
*/ |
| 10 |
int dtclose(Dt_t* dt) |
| 11 |
{ |
| 12 |
if(!dt || dt->nview > 0 ) /* can't close if being viewed */ |
| 13 |
return -1; |
| 14 |
|
| 15 |
if(dt->view) /* turn off viewing */ |
| 16 |
dtview(dt,NULL); |
| 17 |
|
| 18 |
/* release all allocated data */ |
| 19 |
(void)dt->meth->searchf(dt, NULL, DT_CLEAR); |
| 20 |
if(dtsize(dt) > 0) |
| 21 |
return -1; |
| 22 |
|
| 23 |
if (dt->data.ntab > 0) |
| 24 |
free(dt->data.htab); |
| 25 |
|
| 26 |
free(dt); |
| 27 |
|
| 28 |
return 0; |
| 29 |
} |