blob: ab356de95e35f52db255a57a21e45d76143f2fcf [file] [log] [blame]
Harald Welte52b1f982008-12-23 20:25:15 +00001/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
2 * All Rights Reserved
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 */
19
20
21#include <unistd.h>
22#include <stdlib.h>
23#include <sys/types.h>
24
25#include "msgb.h"
26
27struct msgb *msgb_alloc(u_int16_t size)
28{
29 struct msgb *msg = malloc(sizeof(*msg) + size);
30
31 if (!msg)
32 return NULL;
33
34 msg->data_len = size;
35 msg->len = 0;
36 msg->data = msg->_data;
37
38 msg->head = msg->data;
39 msg->data = msg->data;
40 /* reset tail pointer */
41 msg->tail = msg->data - msg->head;
42 //msg->end = msg->tail + size;
43
44 return msg;
45}
46
47void msgb_free(struct msgb *m)
48{
49 free(m);
50}