示例#1
0
CRB_Value
crb_nv_fopen_proc(CRB_Interpreter *interpreter,
                  CRB_LocalEnvironment *env,
                  int arg_count, CRB_Value *args)
{
    CRB_Value value;
    char *filename;
    char *mode;
    FILE *fp;

    check_argument_count(arg_count, 2);

    if (args[0].type != CRB_STRING_VALUE
        || args[1].type != CRB_STRING_VALUE) {
        crb_runtime_error(0, FOPEN_ARGUMENT_TYPE_ERR,
                          MESSAGE_ARGUMENT_END);
    }

    filename = CRB_wcstombs_alloc(args[0].u.object->u.string.string);
    mode = CRB_wcstombs_alloc(args[1].u.object->u.string.string);

    fp = fopen(filename, mode);
    if (fp == NULL) {
        value.type = CRB_NULL_VALUE;
    } else {
        value.type = CRB_NATIVE_POINTER_VALUE;
        value.u.native_pointer.info = &st_native_lib_info;
        value.u.native_pointer.pointer = fp;
    }
    MEM_free(filename);
    MEM_free(mode);

    return value;
}
示例#2
0
文件: create.c 项目: rod-lin/Ivory
UsingList *
Ivyc_create_using_list(PackageName *package_name)
{
    UsingList *rl;
    Ivyc_Compiler *compiler;
    char *current_package_name;
    char *req_package_name;

    compiler = Ivyc_get_current_compiler();

    current_package_name = Ivyc_package_name_to_string(compiler->package_name);
    req_package_name = Ivyc_package_name_to_string(package_name);
    if (ISandBox_compare_string(req_package_name, current_package_name)
        && compiler->source_suffix == IVH_SOURCE) {
        Ivyc_compile_error(compiler->current_line_number,
                          USING_ITSELF_ERR, MESSAGE_ARGUMENT_END);
    }
    MEM_free(current_package_name);
    MEM_free(req_package_name);

    rl = Ivyc_malloc(sizeof(UsingList));
    rl->package_name = package_name;
	rl->source_suffix = IVH_SOURCE;
    rl->line_number = Ivyc_get_current_compiler()->current_line_number;
    rl->next = NULL;

    return rl;
}
示例#3
0
void TC_end()
{
    // initialized ?
    if (uploads != NULL)
    {
        // disabled tile cache Int processing
        VIntProcess &= ~PROCESS_TILECACHE_TASK;

        // release the last uploaded tileset(s)
        if (uploadDone)
        {
            TileSet** tilesets = uploads;
            u16 i = uploadIndex;

            while(i--)
            {
                TileSet* tileset = *tilesets++;

                // released the tileset if we unpacked it here
                if (tileset->compression != COMPRESSION_NONE)
                    MEM_free(tileset);
            }
        }

        // release cache structures memory
        MEM_free(uploads);
        uploads = NULL;
    }
}
示例#4
0
文件: interface.c 项目: 3man/devlang
void
DKC_dispose_compiler(DKC_Compiler *compiler)
{
    CompilerList *list = NULL;
    CompilerList *pos;
    FunctionDefinition *fd_pos;
    CompilerList *temp;

    list = traversal_compiler(list, compiler);

    for (pos = list; pos; ) {
        for (fd_pos = pos->compiler->function_list; fd_pos;
             fd_pos = fd_pos->next) {
            MEM_free(fd_pos->local_variable);
        }
        while (pos->compiler->required_list) {
            temp = pos->compiler->required_list;
            pos->compiler->required_list = temp->next;
            MEM_free(temp);
        }
        MEM_dispose_storage(pos->compiler->compile_storage);
        temp = pos->next;
        MEM_free(pos);
        pos = temp;
    }
}
示例#5
0
/*
 *  ======== DPI_close ========
 */
Static Int DPI_close(DEV_Handle dev)
{
    PipeObj         *pipe = (PipeObj *)dev->object;
    SPipeObj        *sPipe = pipe->sPipe;

    MEM_free(0, pipe, sizeof(PipeObj));
    
    SEM_pend(mutex, SYS_FOREVER);

    sPipe->device[dev->mode] = NULL;
    sPipe->readySem[dev->mode] = NULL;
             
    if (sPipe->device[DEV_INPUT] == NULL &&
                sPipe->device[DEV_OUTPUT] == NULL) {
        /* delete all shared pipe sub-objects */
        SEM_delete(sPipe->dataSem);
        SEM_delete(sPipe->freeSem);

        /* remove sPipe obj from sPipeList */
        QUE_remove(&sPipe->link);
        
        /* delete sPipe object itself */
        MEM_free(0, sPipe, sizeof (SPipeObj));
    }

    SEM_post(mutex);

    return (SYS_OK);
}
示例#6
0
/*
 *  ======== DOV_close ========
 */
static Int DOV_close(DEV_Handle device)
{
    DOV_CopyObj *copy = (DOV_CopyObj *)device->object;
    DEV_Frame   *frame;

    /* close underlying device(s) */
    DEV_close(&(copy->dobj));

    /* move frames _up_ from downstream device */
    while (!QUE_empty(copy->dobj.todevice)) {
        frame = QUE_get(copy->dobj.todevice);

        frame->size = frame->size + copy->size;
        frame->addr = (Char *)frame->addr - copy->size;

        QUE_put(device->todevice, frame);
    }

    QUE_delete(copy->dobj.todevice);
    QUE_delete(copy->dobj.fromdevice);

    /* free overlap buffer */
    MEM_free(0, copy->overlap, copy->size);

    /* recycle copy object */ 
    MEM_free(0, copy, sizeof(DOV_CopyObj));

    return (SYS_OK);
}
示例#7
0
void smeMAP_Unload(smeMap* map)
{
    MEM_free(map->PlaneB->Tiles);
    map->PlaneB->Tiles = NULL;
    MEM_free(map->PlaneA->Tiles);
    map->PlaneA->Tiles = NULL;
}
示例#8
0
文件: heap.c 项目: MrAiki/LL1LL
/* 配列の再帰的領域解放 : 要素から先にマークを確認し, 開放していく */
static void array_sweep(LL1LL_Object *ary_ptr)
{
  int i;
  LL1LL_Value ary_i;

  /* 配列要素のスイープ */
  for (i = 0; i < ary_ptr->u.ary.size; i++) {
    ary_i = ary_ptr->u.ary.array_value[i];  /* 要素を取得 */
    if (ary_i.type != LL1LL_OBJECT_TYPE) {
      /* オブジェクト型でないなら次へ */
      continue;
    } else {
      /* オブジェクト型の場合 */
      if (ary_i.u.object->marked == LL1LL_FALSE) {
        /* マークがFALSE => スイープ(解放) */
        if (ary_i.u.object->type == STRING_OBJECT) {
          MEM_free(ary_i.u.object); /* 文字列ならばそのまま解放 */
        } else {
          /* should be ARRAY_OBJECT here */
          /* 配列ならば要素のスイープ */
          array_sweep(ary_i.u.object);
        }
      }

    }
  }

  /* 大本の配列のスイープ */
  if (ary_ptr->marked == LL1LL_FALSE) {
    MEM_free(ary_ptr);
  }

}
示例#9
0
void SVM_FreeObject(SVMObject *ob) {
  if (ob->fields)
    MEM_free(ob->fields);
  if (ob->names)
    MEM_free(ob->names);
  
  MEM_free(ob);
}
示例#10
0
/*
 *  ======== DEV_rmframe ========
 */
Void DEV_rmframe(DEV_Frame *frame, Int segid, Uns size)
{
    if (size > 0) {
        /* free buffer */
        MEM_free(segid, frame->addr, size);
    }

    /* free object */
    MEM_free(0, frame, sizeof(DEV_Frame));
}
示例#11
0
文件: native.c 项目: BluePanM/code
static CRB_Value
nv_fgets_proc(CRB_Interpreter *interpreter,
              CRB_LocalEnvironment *env,
              int arg_count, CRB_Value *args)
{
    CRB_Value value;
    FILE *fp;
    char buf[LINE_BUF_SIZE];
    char *mb_buf = NULL;
    int ret_len = 0;
    CRB_Char *wc_str;

    CRB_check_argument_count(interpreter, env, arg_count, 1);

    if (args[0].type != CRB_NATIVE_POINTER_VALUE
        || (!CRB_check_native_pointer_type(args[0].u.object,
                                           &st_file_type_info))) {
        CRB_error(interpreter, env, &st_lib_info, __LINE__,
                  (int)FGETS_ARGUMENT_TYPE_ERR,
                  CRB_MESSAGE_ARGUMENT_END);
    }
    check_file_pointer(interpreter,env, args[0].u.object);
    fp = CRB_object_get_native_pointer(args[0].u.object);

    while (fgets(buf, LINE_BUF_SIZE, fp)) {
        int new_len;
        new_len = ret_len + strlen(buf);
        mb_buf = MEM_realloc(mb_buf, new_len + 1);
        if (ret_len == 0) {
            strcpy(mb_buf, buf);
        } else {
            strcat(mb_buf, buf);
        }
        ret_len = new_len;
        if (mb_buf[ret_len-1] == '\n')
            break;
    }
    if (ret_len > 0) {
        wc_str = CRB_mbstowcs_alloc(interpreter, env, __LINE__, mb_buf);
        if (wc_str == NULL) {
            MEM_free(mb_buf);
            CRB_error(interpreter, env, &st_lib_info, __LINE__,
                      (int)FGETS_BAD_MULTIBYTE_CHARACTER_ERR,
                      CRB_MESSAGE_ARGUMENT_END);
        }
        value.type = CRB_STRING_VALUE;
        value.u.object = CRB_create_crowbar_string(interpreter, env, wc_str);
    } else {
        value.type = CRB_NULL_VALUE;
    }
    MEM_free(mb_buf);

    return value;
}
示例#12
0
void raster_free(Raster *raster) {
	hashtable_releaseitems(&raster->verts);
	hashtable_releaseitems(&raster->segments);
	hashtable_releaseitems(&raster->paths);
	hashtable_releaseitems(&raster->styles);
	hashtable_releaseitems(&raster->textures);
	hashtable_release(&raster->master);

	MEM_free(raster->buffer);
	MEM_free(raster);
}
示例#13
0
文件: dispose.c 项目: 3man/devlang
static void
dispose_local_variable(int local_variable_count,
                       DVM_LocalVariable *local_variable)
{
    int i;

    for (i = 0; i < local_variable_count; i++) {
        MEM_free(local_variable[i].name);
        dispose_type_specifier(local_variable[i].type);
    }
    MEM_free(local_variable);
}
示例#14
0
static void _remove ( list *list, listNode *node )
{
	if ( list->freeFn )
	{
		list->freeFn ( node->data );
	}

	list->length--;

	MEM_free ( node->data );
	MEM_free ( node );
}
示例#15
0
void 		bfqDelete			( BufferQueue_Handle queue )
{
	Int i;
	
	// only have to free the buffers.
	for (i=0; i<queue->BufCount; i++)
		MEM_free( queue->SegId, queue->Frames[i].Buffer, queue->BufSize );
		
	// de-allocate the frames if they were allocate within the queue
	if (queue->bDynamicFrames)
		MEM_free( 0, queue->Frames, sizeof(BufferQueue_Frame) * queue->BufCount );
}
示例#16
0
文件: dispose.c 项目: 3man/devlang
static void
dispose_enum(DVM_Enum *enum_type)
{
    int i;

    MEM_free(enum_type->package_name);
    MEM_free(enum_type->name);

    for (i = 0; i < enum_type->enumerator_count; i++) {
        MEM_free(enum_type->enumerator[i]);
    }
    if (enum_type->is_defined) {
        MEM_free(enum_type->enumerator);
    }
}
示例#17
0
static CRB_Value
call_native_function(CRB_Interpreter *inter, LocalEnviroment *env,
        Exprssion *expr, CRB_NativeFunctionProc *proc)
{
    CRB_Value value;
    int arg_count;
    ArgumentList *arg_p;
    CRB_Value *args;
    int i;

    for(arg_count = 0, arg_p = expr->u.function_call_expression.argument;
            arg_p;arg_p = arg_p->next){
        arg_count++;
    }

    arg = MEM_malloc(sizeof(CRB_Value) * arg_count);

    for(arg_p = expr->u.function_call_expression.argument, i = 0;
            arg_p; arg_p = arg_p->next, i++){
        args[i] = eval_expression(inter, env, arg_p->next);
    }
    val = proc(inter, arg_count, args);
    for( i = 0;i < arg_count;i++){
        release_if_string(&args[i]);
    }
    MEM_free(args);

    return value;
}
示例#18
0
//-------------------------------------------------------------------------
// FUNCTION     : NdpAddDataToNeighborCache()
//
// PURPOSE      : Adding data to neighbor cache
//
// PARAMETERS   : neighborCache - pointer to neighbor cache
//                neighborData - neighbor data to be added
//
// RETURN VALUE : None
//-------------------------------------------------------------------------
static
void NdpAddDataToNeighborCache(
    NdpNeighborTable* neighborCache,
    NdpNeighborStruct* neighborData)
{
    if (neighborCache && neighborData)
    {
        if (neighborCache->numEntry == neighborCache->maxEntry)
        {
            unsigned int newNeighborCacheSize = (unsigned int)
                ((neighborCache->numEntry + NDP_INITIAL_CACHE_ENTRY)
                    * sizeof(NdpNeighborStruct));

            NdpNeighborStruct* tempCache = (NdpNeighborStruct*)
                MEM_malloc(newNeighborCacheSize);
            memset(tempCache, 0, newNeighborCacheSize);

            memcpy(tempCache, neighborCache->neighborTable,
                (sizeof(NdpNeighborStruct) * neighborCache->numEntry));

            MEM_free(neighborCache->neighborTable);

            neighborCache->neighborTable = tempCache;

            neighborCache->maxEntry = neighborCache->numEntry
                                      + NDP_INITIAL_CACHE_ENTRY;
        }
        memcpy(&(neighborCache->neighborTable[neighborCache->numEntry]),
            neighborData, sizeof(NdpNeighborStruct));

        neighborCache->numEntry++;
    }// end if (neighborCache && neighborData)
}
示例#19
0
文件: create.c 项目: rod-lin/Ivory
static UsingList *
add_default_package(UsingList *using_list)
{
    UsingList *req_pos;
    ISandBox_Boolean default_package_usingd = ISandBox_FALSE;

    for (req_pos = using_list; req_pos; req_pos = req_pos->next) {
        char *temp_name
            = Ivyc_package_name_to_string(req_pos->package_name);
        if (!strcmp(temp_name, ISandBox_Ivory_DEFAULT_PACKAGE)) {
            default_package_usingd = ISandBox_TRUE;
        }
        MEM_free(temp_name);
    }

    if (!default_package_usingd) {
        PackageName *pn;
        UsingList *req_temp;

        pn = Ivyc_create_package_name(ISandBox_Ivory_DEFAULT_PACKAGE_P1);
        pn = Ivyc_chain_package_name(pn, ISandBox_Ivory_DEFAULT_PACKAGE_P2);
        req_temp = using_list;
        using_list = Ivyc_create_using_list(pn);
        using_list->next = req_temp;
    }
    return using_list;
}
示例#20
0
static void addToUploadQueue(TileSet *tileset, u16 index)
{
    // need to clear to queue ?
    if (uploadDone)
    {
        TileSet** tilesets = uploads;
        u16 i = uploadIndex;

        while(i--)
        {
            TileSet* ts = *tilesets++;

            // released the tileset if we unpacked it here
            if (ts->compression != COMPRESSION_NONE)
                MEM_free(ts);
        }

        // prepare for new upload
        uploadDone = FALSE;
        uploadIndex = 0;
    }

    // set upload tileset info
    uploads[uploadIndex++] = tileset;

    // put in DMA queue
    DMA_queueDma(DMA_VRAM, (u32) tileset->tiles, index * 32, tileset->numTile * 16, 2);
}
示例#21
0
文件: heap.c 项目: MrAiki/LL1LL
/* GCのスイープフェーズ */
static void gc_sweep(void)
{
  LL1LL_Object *pos, *sweep_entry;

  /* ヒープ領域管理リストを走査し, マークが付いてない
   * オブジェクトをリストから削除し, 開放していく */
  for (pos = heap_head; pos != NULL; pos = pos->next) {
    /* マークが付いてないオブジェクトを発見 */
    if (pos->marked == LL1LL_FALSE) {
      /* 削除・解放するエントリを設定 */
      sweep_entry = pos; 

      /* リストから削除 */
      if (pos == heap_head) {
        /* 先頭の場合は, 先頭を削除してから先頭を再設定 */
        deleteHeapEntry(sweep_entry);
        pos = heap_head;
      } else {
        /* 次のループに備えて一個前に戻る */ 
        pos = pos->prev;
        deleteHeapEntry(sweep_entry);
      }

      /* 領域解放 */
      if (sweep_entry->type == STRING_OBJECT) {
        MEM_free(sweep_entry);
      } else {
        /* should be ARRAY_OBJECT here */
        array_sweep(sweep_entry);
      }
    }  
  }

}
示例#22
0
/******************************************************************************
 * Fifo_create
 ******************************************************************************/
Fifo_Handle Fifo_create(Fifo_Attrs *attrs)
{
    Fifo_Handle hFifo;
    BUF_Attrs bAttrs = BUF_ATTRS;

    if (attrs == NULL) {
        return NULL;
    }
    
    hFifo = MEM_calloc(Dmai_Bios_segid, sizeof(Fifo_Object), 0);

    if (hFifo == NULL) {
        Dmai_err0("Failed to allocate space for Fifo Object\n");
        return NULL;
    }
    
    /* Allocate a buffer pool for messages */
    bAttrs.segid = Dmai_Bios_segid;
    hFifo->hBufPool = BUF_create(attrs->maxElems, sizeof(Fifo_Elem), 0, &bAttrs);
    if (hFifo->hBufPool == NULL) {
        Dmai_err0("Failed to allocate space for buffer pool\n");
        MEM_free(Dmai_Bios_segid, hFifo, sizeof(Fifo_Object));
        return NULL;
    }
    
    /* initialize the object */
    QUE_new(&hFifo->queue);
    SEM_new(&hFifo->sem, 0);
    SEM_new(&hFifo->mutex, 1);

    return hFifo;
}
示例#23
0
文件: gio.c 项目: CheredHerry/ti-bios
/*
 *  ======== GIO_delete ========
 */
Int GIO_delete(GIO_Handle gioChan)
{
    IOM_Packet *packet;

    /* flush and delete low-level device ... */
    if (gioChan->fxns != NULL && gioChan->mdChan != NULL) {
        GIO_flush(gioChan);
        gioChan->fxns->mdDeleteChan(gioChan->mdChan);
    }

    /* delete semaphore or alternate sync object ... */
    if (gioChan->syncObj != NULL) {
        GIO->SEMDELETE(gioChan->syncObj);
    }

    /* free frames ... */
    packet = QUE_get(&gioChan->freeList);
    while (packet != (IOM_Packet *)(&gioChan->freeList)) {
        _GIO_rmPacket(packet);
        packet = QUE_get(&gioChan->freeList);
    }

    /* free GIO object. */
    (Void)MEM_free(0, gioChan, sizeof(GIO_Obj));

    return (IOM_COMPLETED);
}
示例#24
0
文件: string.c 项目: 3man/devlang
void
dkc_reset_string_literal_buffer(void)
{
    MEM_free(st_string_literal_buffer);
    st_string_literal_buffer = NULL;
    st_string_literal_buffer_size = 0;
    st_string_literal_buffer_alloc_size = 0;
}
示例#25
0
// Copyright (c) 2001-2013, SCALABLE Network Technologies, Inc.  All Rights Reserved.
//                          600 Corporate Pointe
//                          Suite 1200
//                          Culver City, CA 90230
//                          [email protected]
//
// This source code is licensed, not sold, and is subject to a written
// license agreement.  Among other things, no portion of this source
// code may be copied, transmitted, disclosed, displayed, distributed,
// translated, used as the basis for a derivative work, or used, in
// whole or in part, for any program or purpose other than its intended
// use in compliance with the license agreement as part of the QualNet
// software.  This source code and certain of the algorithms contained
// within it are confidential trade secrets of Scalable Network
// Technologies, Inc. and may not be used as the basis for any other
// software, hardware, product or service.

// /**
// PROTOCOL     :: SIP
// LAYER        :  APPLICATION
// REFERENCES   ::
// + whatissip.pdf  : www.sipcenter.com
// + SIP-2003-Future_of_SIP_and_Presence.pdf
// + siptutorial.pdf
// COMMENTS     :: This is implementation of SIP 2.0 as per RFC 3261
// **/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "api.h"
#include "app_util.h"
#include "multimedia_sipmsg.h"
#include "multimedia_sipdata.h"


#define  DEBUG     0

// /**
// FUNCTION   :: SipMsg
// LAYER      :: APPLICATION
// PURPOSE    :: Constructor of the SipMsg class
// PARAMETERS ::
// RETURN     :: NULL
// **/
SipMsg :: SipMsg()
{
    msgType = SIP_INVALID_MSG;
    requestType = INVALID_REQ;
    responseType = INVALID_RES;
    contentLength = 0;
    pBuffer = NULL;
    pLength = 0;
    totHdrLen = 0;
    maxForwards = SIP_MAX_FORWARDS;
    ackType = SIP_ACK_INVALID;

    connectionId = INVALID_ID;
    proxyConnectionId = INVALID_ID;

    fromIp = INVALID_ADDRESS;
    targetIp = INVALID_ADDRESS;

    memset(targetUrl , 0, sizeof(targetUrl));

    via = NULL;
    maxViaCount = SIP_VIA_COUNT;
    viaCount = 0;
    next = NULL;

    memset(from, 0, sizeof(from));
    memset(to, 0, sizeof(to));
    memset(callId, 0, sizeof(callId));
    memset(tagTo, 0, sizeof(tagTo));
    memset(tagFrom, 0, sizeof(tagFrom));
    memset(cSeq, 0, sizeof(cSeq));
    memset(cSeqMsg, 0, sizeof(cSeqMsg));
    memset(contact, 0, sizeof(contact));
    memset(contentType, 0, sizeof(contentType));
    memset(domainName, 0, sizeof(domainName));
    memset(transProto, 0, sizeof(transProto));
    memset(callInfo, 0, sizeof(callInfo));
}


// /**
// FUNCTION   :: SipMsg
// LAYER      :: APPLICATION
// PURPOSE    :: Destructor of the SipMsg class
// PARAMETERS ::
// RETURN     :: NULL
// **/
SipMsg :: ~SipMsg()
{
    if (via != NULL)
    {
        MEM_free(via);
    }
    via = NULL;
}
示例#26
0
// 回收动态分配的字符串缓冲区
void
crb_reset_string_literal()
{
    MEM_free(st_string_literal_buffer);
    st_string_literal_buffer = NULL;
    st_string_literal_buffer_size = 0;
    st_string_literal_buffer_alloc_size = 0;
}
示例#27
0
文件: Cpu.c 项目: Soorma07/dvsdk-dmai
/******************************************************************************
 * Cpu_delete
 ******************************************************************************/
Int Cpu_delete(Cpu_Handle hCpu)
{
    if (hCpu) {
        MEM_free(Dmai_Bios_segid, hCpu, sizeof(Cpu_Object));
    }

    return Dmai_EOK;
}
示例#28
0
文件: dio.c 项目: CheredHerry/ti-bios
/*
 *  ======== cbRmPort ========
 *  Remove a DIO object and cleans up
 */
static Void cbRmPort(DIO_Handle dio)
{
    /* if chanp not NULL, must delete mini-driver channel */
    if (dio->chanp != NULL) {
        dio->fxns->mdDeleteChan(dio->chanp);
    }

    MEM_free(0, dio, sizeof(DIO_Obj));
}
示例#29
0
文件: utils.c 项目: joeedh/cserver
void List_FreeListM(List *list)
{
    ListLink *link, *next;

    for (link=list->first; link; link=next) {
        next = link->next;
        MEM_free(link);
    }
}
示例#30
0
static void svm_obj_ensuresize(SimpleVM *vm, SVMObject *ob, int size) {
  if (size >= ob->size) {
    int newsize = (size+1)*2;
    int *newnames = MEM_malloc(sizeof(*newnames)*newsize);
    val_t *newfields = MEM_malloc(sizeof(*newfields)*newsize);
    
    if (ob->fields) {
      memcpy(newfields, ob->fields, sizeof(*ob->fields)*ob->size);
      memcpy(newnames, ob->names, sizeof(*ob->names)*ob->size);
      
      MEM_free(ob->fields);
      MEM_free(ob->names);
    }
    
    ob->size = newsize;
    ob->names = newnames;
    ob->fields = newfields;
  }
}