Example #1
0
void bg_nle_file_cache_unload(bg_nle_file_cache_t * c, bg_nle_file_handle_t * h)
  {
  if(!c->cache_size_max)
    {
    destroy_handle(h);
    return;
    }
  else if(c->cache_size_max == 1)
    {
    if(c->cache)
      destroy_handle(c->cache);
    c->cache = h;
    h->next = NULL;
    c->cache_size = 1;
    }
  
  h->next = c->cache;
  c->cache = h;
  
  c->cache_size++;
  if(c->cache_size >= c->cache_size_max)
    {
    bg_nle_file_handle_t * tmp;
    
    tmp = c->cache;

    while(tmp->next->next)
      tmp = tmp->next;

    destroy_handle(tmp->next);
    tmp->next = NULL;
    }
  }
Example #2
0
void put_handle (struct shim_handle * hdl)
{
    int ref_count = REF_DEC(hdl->ref_count);

#ifdef DEBUG_REF
    debug("put handle %p(%s) (ref_count = %d)\n", hdl, __handle_name(hdl),
          ref_count);
#endif

    if (!ref_count) {
        if (hdl->fs && hdl->fs->fs_ops &&
            hdl->fs->fs_ops->hput)
            hdl->fs->fs_ops->hput(hdl);

        qstrfree(&hdl->path);
        qstrfree(&hdl->uri);

        if (hdl->pal_handle)
            DkObjectClose(hdl->pal_handle);

        if (hdl->dentry)
            put_dentry(hdl->dentry);

        if (hdl->fs)
            put_mount(hdl->fs);

        destroy_handle(hdl);
    }
}
Example #3
0
void bg_nle_file_cache_destroy(bg_nle_file_cache_t * c)
  {
  bg_nle_file_handle_t * tmp;
  if(c->cache)
    {
    while(c->cache)
      {
      tmp = c->cache->next;
      destroy_handle(c->cache);
      c->cache = tmp;
      }
    }
  free(c);
  }
/** free object resources, but not the object itself */
void vg_free_object(struct vg_object *obj)
{
   obj->type = 0;
   obj->ctx = NULL;
   destroy_handle(obj->handle);
}
Example #5
0
int avcodec(void *handle, avc_cmd_t cmd, void* pin, void* pout)
{
    AVCodecContext* ctx = handle;
    switch (cmd)
    {
    case AVC_OPEN_BY_NAME:
    {
        // pin  char* codec name
        private_handle_t* h = create_handle();
        (private_handle_t**)pout = h;
        if (!h)
            return -ENOMEM;
        if (!h->avcodec)
        {
            destroy_handle(h);
            (private_handle_t**)pout = NULL;
            return -1;// better error
        }
        return 0;
    }
    case AVC_OPEN_BY_CODEC_ID:
    {
        // pin  uint32_t codec fourcc
        private_handle_t* h = create_handle();
        (private_handle_t**)pout = h;
        if (!h)
            return -ENOMEM;

        if (!h->avcodec)
        {
            destroy_handle(h);
            (private_handle_t**)pout = NULL;
            return -1;// better error
        }
        return 0;
    }
    case AVC_OPEN_BY_FOURCC:
    {
        // pin  uint32_t codec fourcc
        private_handle_t* h = create_handle();
        (private_handle_t**)pout = h;
        if (!h)
            return -ENOMEM;
        h->avcodec = avcodec_find_by_fcc((uint32_t) pin);
        if (!h->avcodec)
        {
            destroy_handle(h);
            (private_handle_t**)pout = NULL;
            return -1;// better error
        }
        return 0;
    }
    case AVC_CLOSE:
        // uninit part
        // eventually close all allocated space if this was last
        // instance
        destroy_handle(handle);
        break;

    case AVC_FLUSH:
        break;

    case AVC_DECODE:
        break;

    case AVC_ENCODE:
        break;

    case AVC_GET_VERSION:
        (int*) pout = 500;
    default:
        return -1;

    }
    return 0;
}