Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
att
GitHub Repository: att/ast
Path: blob/master/src/lib/libvcodex/vcclose.c
1808 views
1
/***********************************************************************
2
* *
3
* This software is part of the ast package *
4
* Copyright (c) 2003-2011 AT&T Intellectual Property *
5
* and is licensed under the *
6
* Eclipse Public License, Version 1.0 *
7
* by AT&T Intellectual Property *
8
* *
9
* A copy of the License is available at *
10
* http://www.eclipse.org/org/documents/epl-v10.html *
11
* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
12
* *
13
* Information and Software Systems Research *
14
* AT&T Research *
15
* Florham Park NJ *
16
* *
17
* Phong Vo <[email protected]> *
18
* *
19
***********************************************************************/
20
#include "vchdr.h"
21
22
/* Close a Vcodex_t handle
23
**
24
** Written by Kiem-Phong Vo ([email protected])
25
*/
26
27
#if __STD_C
28
int vcclose(Vcodex_t* vc)
29
#else
30
int vcclose(vc)
31
Vcodex_t* vc;
32
#endif
33
{
34
if(!vc)
35
return -1;
36
37
if(vc->disc && vc->disc->eventf &&
38
(*vc->disc->eventf)(vc, VC_CLOSING, NIL(Void_t*), vc->disc) < 0 )
39
return -1;
40
41
vcbuffer(vc, NIL(Vcchar_t*), -1, -1); /* free all cached buffers */
42
43
if(vc->coder && (vc->flags&VC_CLOSECODER) && vcclose(vc->coder) < 0 )
44
return -1;
45
46
if(vcfreecontext(vc, NIL(Vccontext_t*)) < 0 )
47
return -1;
48
49
if(vc->meth && vc->meth->eventf &&
50
(*vc->meth->eventf)(vc, VC_CLOSING, NIL(Void_t*)) < 0 )
51
return -1;
52
53
free(vc);
54
55
return 0;
56
}
57
58