⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fad.dynarray.c

📁 libFAD is a Flash Animation Decode library
💻 C
字号:
/** * libFAD - Flash Animation Decode library * Copyright (C) 2005-2006 VGSystem Technologies, Inc. * * libFAD is the legal property of its developers, whose names are too numerous * to list here.  Please refer to the COPYRIGHT file distributed with this * source distribution. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU Library General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * $Id: fad.dynarray.c,v 1.11 2005/10/07 09:41:44 wrxzzj Exp $ */#include "fad.dynarray.h"#define FAD_DYNARRAY_DEFAULT_STEP 1024static void _da_put(dynarray_t* da, void* ptr, u16_t idx) {  u16_t offset = da->total;  if(ptr == NULL) {    if(idx < da->total) {      da->array[idx] = NULL;      da->count--;    }  } else {   while(idx >= da->total) {      da->total += da->step;      da->array = (void** )realloc(da->array, da->total*sizeof(void*));      offset = da->total;    }    da->array[idx] = ptr;    da->count++;  }}static void* _da_get(dynarray_t* da, u16_t idx) {  if(idx >= da->total)    return NULL;  return da->array[idx];}void da_init(dynarray_t* da, u16_t step) {  if(step == 0)    step = FAD_DYNARRAY_DEFAULT_STEP;  da->step = step;  da->total = step;  da->count = da->ref = 0;  da->array = (void** )calloc(step, sizeof(void*));  da->put = _da_put;  da->get = _da_get;}void da_finish(dynarray_t* da) {  if(da->array)    free(da->array);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -