2
The mediastreamer library aims at providing modular media processing and I/O
3
for linphone, but also for any telephony application.
4
Copyright (C) 2001 Simon MORLAT simon.morlat@linphone.org
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
MSBuffer * ms_buffer_new(guint32 size)
30
buf=(MSBuffer*)g_malloc(sizeof(MSBuffer)+size);
33
ms_trace("ms_buffer_new: Allocating buffer of %i bytes.",size);
34
/* allocate the data buffer: there is a lot of optmisation that can be done by using a pool of cached buffers*/
35
buf->buffer=(char*) (buf+1); /* to avoid to do two allocations,
36
buffer info and buffer are contigous.*/
37
buf->flags=MS_BUFFER_CONTIGUOUS;
41
MSBuffer *ms_buffer_alloc(gint flags)
44
buf=(MSBuffer*)g_malloc(sizeof(MSBuffer));
53
void ms_buffer_destroy(MSBuffer *buf)
55
if (buf->flags & MS_BUFFER_CONTIGUOUS){
64
MSMessage *ms_message_alloc()
66
MSMessage *m=g_malloc(sizeof(MSMessage));
67
memset(m,0,sizeof(MSMessage));
71
MSMessage *ms_message_new(gint size)
73
MSMessage *m=ms_message_alloc();
74
MSBuffer *buf=ms_buffer_new(size);
75
ms_message_set_buf(m,buf);
79
void ms_message_destroy(MSMessage *m)
81
/* the buffer is freed if its ref_count goes to zero */
83
m->buffer->ref_count--;
84
if (m->buffer->ref_count==0) ms_buffer_destroy(m->buffer);
89
MSMessage * ms_message_dup(MSMessage *m)
91
MSMessage *msg=ms_message_alloc();
92
ms_message_set_buf(msg,m->buffer);