Exemplo n.º 1
0
void sqpFreeSelect( void *pData )
{
	HSQPSELECT pSelect = (HSQPSELECT)pData;

#ifdef SQPDEBUG
	printf( "[SQP][%s][%d]\n", __FILE__, __LINE__ );
#endif

	if ( !pSelect )
		return;

	if ( pSelect->hColumns )
	{
		lstSetFreeFunc( pSelect->hColumns, sqpFreeColumn );
		lstClose( pSelect->hColumns );
	}
	if ( pSelect->hWhere )
	{
		sqpFreeCond( pSelect->hWhere );
	}
	if ( pSelect->pszTable )
		free( pSelect->pszTable );
	if ( pSelect->hOrderBy )
	{
		lstSetFreeFunc( pSelect->hOrderBy, sqpFreeColumn );
		lstClose( pSelect->hOrderBy );
	}
	
    free( pSelect );

#ifdef SQPDEBUG
	printf( "[SQP][%s][%d]\n", __FILE__, __LINE__ );
#endif

}
Exemplo n.º 2
0
/*! 
 * \brief   Closes log.
 * 
 *          This will clear all messages and close the log. All memory used
 *          by the messages is automatically freed by calls to _logFreeMsg.
 *          All remaining mem used by the log is also freed - including the
 *          log handle itself.
 *
 * \param   hLog    A log handle init by \sa logOpen.
 * 
 * \return  int
 * \retval  LOG_SUCCESS
 *
 * \sa      logOpen
 */
int logClose( HLOG hLog )
{
    /* we must be logOpen to logClose */
	if ( !hLog ) return LOG_ERROR;

    /* clear all messages - including the handle                */
    /* _logFreeMsg will automatically be called for each msg    */
    lstClose( hLog->hMessages );

    /* free remaining mem used by log - including the handle    */
	if ( hLog->pszProgramName ) free( hLog->pszProgramName );
	if ( hLog->pszLogFile ) free( hLog->pszLogFile );
	free( hLog );

	return LOG_SUCCESS;
}
Exemplo n.º 3
0
/*********************
 * lstClose
 *
 * Call for Cursor or root list.
 *********************/
int lstClose( HLST hLst )
{
	HLSTITEM hItem;

    if ( !hLst )
        return LST_ERROR;

    hLst->nRefs--;

	/*********************
	 * We will not really remove the list if we have
	 * refs to it... we will just decrement ref.
	 * We will be deleted when the last ref is being removed.
	 *********************/
	if ( hLst->nRefs > 0 )
		return LST_SUCCESS;

	/************************
	 * DELETE ITEMS (and their refs)
	 * - do not use standard nav funcs because they will skip items where bDelete
	 ************************/
	hItem = hLst->hFirst;
	while ( hItem )
	{
        _lstFreeItem( hItem );
		hItem = hLst->hFirst;
	}

	/************************
	 * RECURSE AS REQUIRED. RECURSION WILL STOP AS SOON AS WE GET TO A LIST WHICH
	 * DOES NOT NEED TO BE DELETED YET (refs >= 0).
	 ************************/
	if ( hLst->hLstBase )						/* we are a cursor 					*/
		lstClose( hLst->hLstBase );				/* dec ref count and close if < 0 	*/

	/************************
	 * FREE LIST HANDLE
	 ************************/
	free( hLst );

	return LST_SUCCESS;
}
Exemplo n.º 4
0
/*
    Listing loader callback. This is invoked at key points when loading a module file.
 */
void emListingLoadCallback(Ejs *ejs, int kind, ...)
{
    va_list         args;
    EjsModuleHdr    *hdr;
    EjsMod          *mp;
    Lst             *lst;
    MprList         *modules;
    char            *name;
    int             nextModule;

    va_start(args, kind);
    mp = ejs->loadData;
    lst = mprAlloc(sizeof(Lst));

    /*
        Decode the record type and create a list for later processing. We need to process
        after the loader has done fixup for forward type references.
     */
    switch (kind) {

    case EJS_SECT_BLOCK:
        lst->module = va_arg(args, EjsModule*);
        lst->owner = va_arg(args, EjsObj*);
        lst->slotNum = va_arg(args, int);
        lst->name = va_arg(args, EjsString*);
        lst->numProp = va_arg(args, int);
        break;

    case EJS_SECT_BLOCK_END:
        break;

    case EJS_SECT_CLASS:
        lst->module = va_arg(args, EjsModule*);
        lst->slotNum = va_arg(args, int);
        lst->qname = va_arg(args, EjsName);
        lst->type = va_arg(args, EjsType*);
        lst->attributes = va_arg(args, int);
        break;

    case EJS_SECT_CLASS_END:
        break;

    case EJS_SECT_DEPENDENCY:
        lst->module = va_arg(args, EjsModule*);
        lst->dependency = va_arg(args, EjsModule*);
        break;

    case EJS_SECT_END:
        modules = va_arg(args, MprList*);
        nextModule = va_arg(args, int);
        lstClose(mp, modules, nextModule);
        return;

    case EJS_SECT_EXCEPTION:
        lst->module = va_arg(args, EjsModule*);
        lst->fun = va_arg(args, EjsFunction*);
        break;

    case EJS_SECT_FUNCTION:
        lst->module = va_arg(args, EjsModule*);
        lst->owner = va_arg(args, EjsObj*);
        lst->slotNum = va_arg(args, int);
        lst->qname = va_arg(args, EjsName);
        lst->fun = va_arg(args, EjsFunction*);
        lst->attributes = va_arg(args, int);
        break;

    case EJS_SECT_FUNCTION_END:
        break;

    case EJS_SECT_START:
        name = va_arg(args, char*);
        hdr = va_arg(args, EjsModuleHdr*);
        lstOpen(mp, name, hdr);
        return;

    case EJS_SECT_PROPERTY:
        lst->module = va_arg(args, EjsModule*);
        lst->owner = va_arg(args, EjsObj*);
        lst->slotNum = va_arg(args, int);
        lst->qname = va_arg(args, EjsName);
        lst->attributes = va_arg(args, int);
        lst->typeName = va_arg(args, EjsName);
        break;

    case EJS_SECT_MODULE:
        break;

    case EJS_SECT_MODULE_END:
        break;
            
    case EJS_SECT_DEBUG:
        break;

    default:
        mprAssert(0);
    }
    lst->kind = kind;
    mprAddItem(mp->lstRecords, lst);
}