stack.h

来自「在linux下的crawler程序,来自北大天网tiny search engi」· C头文件 代码 · 共 43 行

H
43
字号
#ifndef _STACK_H_#define _STACK_H_#define STACK_INITIAL_SIZE	256/* Do NOT manipulate the __stack structure directly unless you know what * you are doning. */struct __stack{	char *base;	unsigned int size;	char *top;};typedef struct __stack stack_t;#ifdef __cplusplusextern "C"{#endifstack_t *stack_create(unsigned int isize);#define stack_push(elem, type, stack) \({																			\	(stack)->top + sizeof (type) <= (stack)->base + (stack)->size ||		\		__stack_expand(stack, sizeof (type)) >= 0 ?							\	*((type *)(stack)->top)++ = (elem), (stack)->top - (stack)->base : -1;	\})#define stack_pop(type, stack)	(*--(type *)(stack)->top)#define stack_top(type, stack)	(*((type *)(stack)->top - 1))#define stack_height(stack)		((stack)->top - (stack)->base)#define stack_empty(stack)		((stack)->base == (stack)->top)void stack_destroy(stack_t *stack);/* Never call the following function directly. */int __stack_expand(stack_t *stack, unsigned int esize);#ifdef __cplusplus}#endif#endif

⌨️ 快捷键说明

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