Commit d81f9639 authored by Niels Möller's avatar Niels Möller

* list.c (make_int_listv): New function

(make_object_listv): New function

Rev: src/list.c:1.4
Rev: src/list.h:1.3
parent 8ec59abe
......@@ -34,15 +34,12 @@
#include "xalloc.h"
struct int_list *make_int_list(unsigned n, ...)
struct int_list *make_int_listv(unsigned n, va_list args)
{
unsigned i;
va_list args;
struct int_list *l = alloc_int_list(n);
va_start(args, n);
for (i=0; i<n; i++)
{
int atom = va_arg(args, int);
......@@ -55,15 +52,24 @@ struct int_list *make_int_list(unsigned n, ...)
return l;
}
struct object_list *make_object_list(unsigned n, ...)
struct int_list *make_int_list(unsigned n, ...)
{
unsigned i;
va_list args;
struct int_list *l;
struct object_list *l = alloc_object_list(n);
va_start(args, n);
l = make_int_listv(n, args);
va_end(args);
return l;
}
struct object_list *make_object_listv(unsigned n, va_list args)
{
unsigned i;
struct object_list *l = alloc_object_list(n);
for (i=0; i<n; i++)
LIST(l)[i] = va_arg(args, struct lsh_object *);
......@@ -72,3 +78,16 @@ struct object_list *make_object_list(unsigned n, ...)
return l;
}
struct object_list *make_object_list(unsigned n, ...)
{
va_list args;
struct object_list *l;
va_start(args, n);
l = make_object_listv(n, args);
va_end(args);
return l;
}
......@@ -28,6 +28,8 @@
#include "lsh_types.h"
#include <stdarg.h>
#define CLASS_DECLARE
#include "list.h.x"
#undef CLASS_DECLARE
......@@ -66,12 +68,14 @@ struct list_header *lsh_list_alloc(struct lsh_class *class,
#define alloc_int_list(n) \
((struct int_list *) lsh_list_alloc(&CLASS(int_list), (n), sizeof(int)))
struct int_list *make_int_listv(unsigned length, va_list args);
struct int_list *make_int_list(unsigned length, ...);
#define alloc_object_list(n) \
((struct object_list *) \
lsh_list_alloc(&CLASS(object_list), (n), sizeof(struct lsh_object *)))
struct object_list *make_object_listv(unsigned length, va_list args);
struct object_list *make_object_list(unsigned length, ...);
#endif /* LSH_LIST_H_INCLUDED */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment