Example #1
0
int fclose(FILE *fp)
{
	int r;

	if (fp->_flags == 0)  	/* not open! */
	{
		errno = EBADF;
		return (EOF);
	}
	FLOCKFILE(fp);
	r = fp->_flags & __SWR ? __sflush(fp) : 0;
	if (fp->_close != NULL && (*fp->_close)(fp->_cookie) < 0)
		r = EOF;
	if (fp->_flags & __SMBF)
		FREE((char *)fp->_bf._base);
	if (HASUB(fp))
		FREEUB(fp);
	if (HASLB(fp))
		FREELB(fp);
	fp->_file = -1;
	fp->_r = fp->_w = 0;	/* Mess up if reaccessed. */
	fp->_flags = 0;		/* Release this FILE for reuse. */
	osal_mutex_delete(fp->_extra->fl_mutex);
	
	FUNLOCKFILE(fp);
	return (r);
}
Example #2
0
void tr_lockClose( tr_lock_t * l )
{
	osal_mutex_delete(*l);
	*l = INVALID_ID;
}