i am writing a code using mblk/dblk. I have implemented my own allocb function. Hopefully it is right.
When i try to assign the buff to the dblk_t structure element (the statement shown in bold) i get an error. If i comment out that line everything works fine.
Am i doing something wrong.
Can someone help me assign the buff to db_base of the struct dblk_t
Code:
struct dblk_t {
struct dblk_t *db_freep; /* internal use */
unsigned char *db_base; /* first byte of buffer */
unsigned char *db_lim; /* last byte +1 of buffer */
unsigned char *db_vbase; /* first byte of system buffer */
int (*db_cb)(); /* callback routine */
unsigned long int db_size;
unsigned char db_ref; /* count of to this block */
unsigned char db_type; /* message type */
unsigned char db_class; /* internal use */
unsigned char db_id;
};
struct mblk_t {
struct mblk_t *b_next; /* next message on queue */
struct mblk_t *b_prev; /* previous message on queue */
struct mblk_t *b_cont; /* next message block of message */
unsigned char *b_rptr; /* first unread data byte in message */
unsigned char *b_wptr; /* first unwritten data byte inbuffer*/
struct dblk_t *b_datap; /* data block */
};
struct mblk_t* allocb(int size)
{
struct mblk_t *mp;
struct mblk_t mp1;
mp=&mp1;
unsigned char buff[size];
mp->b_rptr=buff;
mp->b_wptr=buff;
mp->b_datap->db_base=buff;
return mp;
}
