Added vpbuffer utility functions

This commit is contained in:
Justin Ethier 2019-10-09 19:01:53 -04:00
parent 1551c9a8b7
commit 4cb5b1db40
2 changed files with 25 additions and 0 deletions

View file

@ -1428,6 +1428,16 @@ typedef union {
/**@}*/
/**@}*/
typedef struct vpbuffer_t vpbuffer;
struct vpbuffer_t {
void **buf;
int len;
int count;
};
vpbuffer *vp_create(void);
void vp_add(vpbuffer *v, void *obj);
/* Utility functions */
void **vpbuffer_realloc(void **buf, int *len);
void **vpbuffer_add(void **buf, int *len, int i, void *obj);

View file

@ -6435,6 +6435,21 @@ void vpbuffer_free(void **buf)
free(buf);
}
vpbuffer *vp_create(void)
{
vpbuffer *v = malloc(sizeof(vpbuffer));
v->len = 128;
v->count = 0;
v->buf = NULL;
v->buf = vpbuffer_realloc(v->buf, &(v->len));
return v;
}
void vp_add(vpbuffer *v, void *obj)
{
v->buf = vpbuffer_add(v->buf, &(v->len), v->count++, obj);
}
object Cyc_bit_unset(void *data, object n1, object n2)
{
Cyc_check_int(data, n1);