libvisual  0.5.0
Macros | Typedefs | Functions | Variables
VisMem

Macros

#define visual_mem_new0(struct_type, n_structs)   ((struct_type *) visual_mem_malloc0 (((visual_size_t) sizeof (struct_type)) * ((visual_size_t) (n_structs))))
 Convenience macro to allocate an array with visual_mem_malloc0(). More...
 

Typedefs

typedef void *(* VisMemCopyFunc )(void *dest, const void *src, visual_size_t n)
 The visual_mem_copy function needs this signature. More...
 
typedef void *(* VisMemCopyPitchFunc )(void *dest, const void *src, int pitch1, int pitch2, int width, int rows)
 The visual_mem_copy_pitch function needs this signature. More...
 
typedef void *(* VisMemSet8Func )(void *dest, int c, visual_size_t n)
 The visual_mem_set function needs this signature. More...
 
typedef void *(* VisMemSet16Func )(void *dest, int c, visual_size_t n)
 The visual_mem_set16 function needs this signature. More...
 
typedef void *(* VisMemSet32Func )(void *dest, int c, visual_size_t n)
 The visual_mem_set32 function needs this signature. More...
 

Functions

void * visual_mem_malloc (visual_size_t size) LV_ATTR_MALLOC
 Allocates a block of memory. More...
 
void * visual_mem_malloc0 (visual_size_t size) LV_ATTR_MALLOC
 Allocates a block of memory with its content zeroed. More...
 
void * visual_mem_realloc (void *ptr, visual_size_t size) LV_ATTR_MALLOC
 Reallocates memory, can be used to grow a buffer. More...
 
void visual_mem_free (void *ptr)
 Frees a memory block allocated by visual_mem_malloc() and visual_mem_realloc(). More...
 
void * visual_mem_malloc_aligned (visual_size_t size, visual_size_t alignment)
 Allocates a memory block aligned to a given address boundary. More...
 
void visual_mem_free_aligned (void *ptr)
 Frees a memory block allocated by visual_mem_alloc_aligned(). More...
 

Variables

VisMemCopyFunc visual_mem_copy
 
VisMemCopyPitchFunc visual_mem_copy_pitch
 
VisMemSet8Func visual_mem_set
 
VisMemSet16Func visual_mem_set16
 
VisMemSet32Func visual_mem_set32
 

Detailed Description

Macro Definition Documentation

#define visual_mem_new0 (   struct_type,
  n_structs 
)    ((struct_type *) visual_mem_malloc0 (((visual_size_t) sizeof (struct_type)) * ((visual_size_t) (n_structs))))

Convenience macro to allocate an array with visual_mem_malloc0().

Parameters
struct_typeType of struct
n_structsNumber of elements
Returns
pointer to newly allocated array

Definition at line 169 of file lv_mem.h.

Typedef Documentation

typedef void*(* VisMemCopyFunc)(void *dest, const void *src, visual_size_t n)

The visual_mem_copy function needs this signature.

  • dest Pointer to the dest buffer.
  • src Pointer to the source buffer.
  • n The number of bytes to be copied.
Returns
Pointer to the dest buffer.

Definition at line 43 of file lv_mem.h.

typedef void*(* VisMemCopyPitchFunc)(void *dest, const void *src, int pitch1, int pitch2, int width, int rows)

The visual_mem_copy_pitch function needs this signature.

This function supports a negative pitch.

  • dest Pointer to the dest buffer.
  • src Pointer to the source buffer.
  • pitch1 The number of bytes a row in the dest buffer.
  • pitch2 The number of bytes a row in the src buffer.
  • width The copy width of each row.
  • rows The number of rows.
Returns
Pointer to the dest buffer.

Definition at line 57 of file lv_mem.h.

typedef void*(* VisMemSet16Func)(void *dest, int c, visual_size_t n)

The visual_mem_set16 function needs this signature.

  • dest Pointer to the dest buffer.
  • c Value that is used as the set value.
  • n The number of words (16bits) to be set.
Returns
Pointer to the dest buffer.

Definition at line 79 of file lv_mem.h.

typedef void*(* VisMemSet32Func)(void *dest, int c, visual_size_t n)

The visual_mem_set32 function needs this signature.

  • dest Pointer to the dest buffer.
  • c Value that is used as the set value.
  • n The number of integers (32bits) to be set.
Returns
Pointer to the dest buffer.

Definition at line 90 of file lv_mem.h.

typedef void*(* VisMemSet8Func)(void *dest, int c, visual_size_t n)

The visual_mem_set function needs this signature.

  • dest Pointer to the dest buffer.
  • c Value that is used as the set value.
  • n The number of bytes to be set.
Returns
Pointer to the dest buffer.

Definition at line 68 of file lv_mem.h.

Function Documentation

void visual_mem_free ( void *  ptr)

Frees a memory block allocated by visual_mem_malloc() and visual_mem_realloc().

Parameters
ptrFrees memory to which ptr points to
Note
visual_mem_free() accepts NULL pointers.

Definition at line 146 of file lv_mem.c.

void visual_mem_free_aligned ( void *  ptr)

Frees a memory block allocated by visual_mem_alloc_aligned().

Parameters
ptrPointer to memory block
Note
visual_mem_free_aligned() accepts NULL pointers.
void* visual_mem_malloc ( visual_size_t  size)

Allocates a block of memory.

Parameters
sizeSize in bytes
Returns
Pointer to newly allocated memory block, or NULL on failure

Definition at line 111 of file lv_mem.c.

Referenced by visual_mem_malloc0().

void* visual_mem_malloc0 ( visual_size_t  size)

Allocates a block of memory with its content zeroed.

Parameters
sizeSize in bytes
Returns
Pointer to newly allocated memory block with its contents zeroed, or NULL on failure

Definition at line 128 of file lv_mem.c.

void* visual_mem_malloc_aligned ( visual_size_t  size,
visual_size_t  alignment 
)

Allocates a memory block aligned to a given address boundary.

Parameters
sizeSize in bytes
alignmentAddress alignment
Returns
pointer to newly allocated memory block at the specified alignment
Note
Memory allocated by this function must be fred by visual_mem_free_aligned().
void* visual_mem_realloc ( void *  ptr,
visual_size_t  size 
)

Reallocates memory, can be used to grow a buffer.

Parameters
ptrPointer to memory block to be reallocated
sizeSize in bytes
Returns
pointer to the reallocated memory block, or NULL on failure

Definition at line 141 of file lv_mem.c.