GstMemChunk

GstMemChunk — Atomic chunk allocator

Synopsis


#include <gst/gst.h>


struct      GstMemChunk;
GstMemChunk* gst_mem_chunk_new              (gchar *name,
                                             gint atom_size,
                                             gulong area_size,
                                             gint type);
void        gst_mem_chunk_destroy           (GstMemChunk *mem_chunk);
gpointer    gst_mem_chunk_alloc             (GstMemChunk *mem_chunk);
gpointer    gst_mem_chunk_alloc0            (GstMemChunk *mem_chunk);
void        gst_mem_chunk_free              (GstMemChunk *mem_chunk,
                                             gpointer mem);

Description

GstMemChunk is an atomic chunk allocator. It uses atomic operations to allocate fixed size memory regions and is therefore thread safe without the overhead of mutexes or other heavyweight locking mechanisms.

The GstMemChunk is used to allocate critical resources for GstBuffer and GstEvent.

Details

struct GstMemChunk

struct GstMemChunk;

The memchunk structure


gst_mem_chunk_new ()

GstMemChunk* gst_mem_chunk_new              (gchar *name,
                                             gint atom_size,
                                             gulong area_size,
                                             gint type);

Creates a new memchunk that will allocate atom_sized memchunks. The initial area is set to area_size and will grow automatically when it is too small (with a small overhead when that happens)

name : the name of the chunk
atom_size : the size of the allocated atoms
area_size : the initial size of the memory area
type : the allocation strategy to use
Returns : a new GstMemChunk

gst_mem_chunk_destroy ()

void        gst_mem_chunk_destroy           (GstMemChunk *mem_chunk);

Free the memory allocated by the memchunk

mem_chunk : the GstMemChunk to destroy

gst_mem_chunk_alloc ()

gpointer    gst_mem_chunk_alloc             (GstMemChunk *mem_chunk);

Allocate a new memory region from the chunk. The size of the allocated memory was specified when the memchunk was created.

mem_chunk : the mem chunk to use
Returns : a pointer to the allocated memory region.

gst_mem_chunk_alloc0 ()

gpointer    gst_mem_chunk_alloc0            (GstMemChunk *mem_chunk);

Allocate a new memory region from the chunk. The size of the allocated memory was specified when the memchunk was created. The memory will be set to all zeroes.

mem_chunk : the mem chunk to use
Returns : a pointer to the allocated memory region.

gst_mem_chunk_free ()

void        gst_mem_chunk_free              (GstMemChunk *mem_chunk,
                                             gpointer mem);

Free the memeory region allocated from the chunk.

mem_chunk : the mem chunk to use
mem : the memory region to hand back to the chunk

See Also

GstAtomic, GstBuffer, GstEvent, GstData