list.h

来自「飞漫公司的minigui的1.6.8收费增值版本的demon等示例程序」· C头文件 代码 · 共 50 行

H
50
字号
/* * Fast list methods * Feb 2000  --Jcid * */#ifndef __LIST_H__#define __LIST_H__/* * a_List_resize() * * Make sure there's space for 'num_items' items within the list * (First, allocate an 'alloc_step' sized chunk, after that, double the *  list size --to make it faster) */#define a_List_resize(list,num_items,alloc_step) \   if ( !list ) { \      list = g_malloc(alloc_step * sizeof((*(list)))); \   } \   if ( num_items >= alloc_step ){ \      while ( num_items >= alloc_step ) \         alloc_step <<= 1; \      list = g_realloc(list, alloc_step * sizeof((*(list)))); \   }/* * a_List_add() * * Make sure there's space for one more item within the list. */#define a_List_add(list,num_items,alloc_step) \   a_List_resize(list,num_items,alloc_step)/* * a_List_remove() * * Quickly remove an item from the list * ==> We preserve relative position, but not the element index <== */#define a_List_remove(list, item, num_items) \   if ( list && item < num_items ) { \      list[item] = list[--num_items]; \   }#endif /* __LIST_H__ */

⌨️ 快捷键说明

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