Commit 07e8b766 authored by Niels Möller's avatar Niels Möller

Add object headers to most structures.

Rev: src/lsh_types.h:1.9
Rev: src/randomness.h:1.4
Rev: src/read_line.h:1.7
Rev: src/write_buffer.h:1.6
parent 2f830289
......@@ -79,9 +79,27 @@ do { \
#define MIN(a, b) (((a)>(b)) ? (b) : (a))
#define MAX(a, b) (((a)>(b)) ? (b) : (a))
/* Generic packet */
/* Generic object */
#ifdef DEBUG_ALLOC
struct lsh_object
{
int type; /* Zero for objects that are not allocated on the heap. */
};
#define STATIC_HEADER { 0 },
#else /* !DEBUG_ALLOC */
struct lsh_object {};
#define STATIC_HEADER
#endif /* !DEBUG_ALLOC */
struct lsh_string
{
struct lsh_object header;
UINT32 sequence_number;
UINT32 length;
UINT8 data[1];
......@@ -92,7 +110,9 @@ struct callback;
typedef int (*callback_f)(struct callback *closure);
struct callback
{
callback_f f;
struct lsh_object header;
int (*f)(struct callback *closure);
};
#define CALLBACK(c) ((c)->f(c))
......
......@@ -30,6 +30,8 @@
struct randomness
{
struct lsh_object header;
void (*random)(struct randomness **closure, UINT32 length, UINT8 *dst);
};
......
......@@ -34,6 +34,8 @@
/* May store a new handler into *h. */
struct line_handler
{
struct lsh_object header;
struct read_handler * (*handler)(struct line_handler **h,
UINT32 length,
UINT8 *line);
......
......@@ -31,6 +31,8 @@
/* For the packet queue */
struct node
{
struct lsh_object header;
struct node *next;
struct node *prev;
struct lsh_string *packet;
......
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