📄 vector.c
字号:
/* vector.c - simple vector management
*
* Modifications:
*
* 12-May-1988 mz Add VECTOR typedef
*
*/
#include <malloc.h>
#include "..\h\tools.h"
#define DELTA 10
VECTOR *VectorAlloc (count)
int count;
{
register VECTOR *v;
v = (VECTOR *) (*tools_alloc) (sizeof (*v) + (count-1) * sizeof (void *));
if (v != NULL) {
v->vmax = count;
v->count = 0;
}
return v;
}
flagType fAppendVector (ppVec, val)
VECTOR **ppVec;
void * val;
{
register VECTOR *pVec = *ppVec;
if (pVec == NULL)
if ((pVec = VectorAlloc (DELTA)) == NULL)
return FALSE;
else
;
else
if (pVec->vmax == pVec->count) {
register VECTOR *v;
if ((v = VectorAlloc (DELTA + pVec->vmax)) == NULL)
return FALSE;
Move ((char far *)(pVec->elem),
(char far *)(v->elem),
sizeof (v->elem[0]) * pVec->count);
v->count = pVec->count;
free ((char *) pVec);
pVec = v;
}
pVec->elem[pVec->count++] = (void *) val;
*ppVec = pVec;
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -