Convenient macros and functions for allocating objects, arrays or 2D arrays.
More...
#include <stdlib.h>
#include <glib.h>
Go to the source code of this file.
|
#define | NEW_INSTANCE(type) g_new(type,1) |
| Allocate a new instance for type type . More...
|
|
#define | NEW_ARRAY_INSTANCE(element_count, element_type) g_new(element_type,element_count) |
| Allocate a new instance array for type type . More...
|
|
#define | NEW_ARRAY2D_INSTANCE(row_size, col_size, element_type) (element_type**) array2D_new(row_size,col_size,sizeof(element_type),sizeof(element_type*)); |
| Allocate a new two dimension array. More...
|
|
This header file lists the macros and functions for allocating instance, 1-D and 2-D instance array of given type.
#define NEW_ARRAY2D_INSTANCE |
( |
|
row_size, |
|
|
|
col_size, |
|
|
|
element_type |
|
) |
| (element_type**) array2D_new(row_size,col_size,sizeof(element_type),sizeof(element_type*)); |
- Parameters
-
row_size | Number of row. |
col_size | Number of column. |
element_type | Element type to be allocated. |
- Returns
- A two dimension array of element type.
#define NEW_ARRAY_INSTANCE |
( |
|
element_count, |
|
|
|
element_type |
|
) |
| g_new(element_type,element_count) |
- Parameters
-
element_count | Number of element to be required. |
element_type | Element type to be allocated. |
- Returns
- A newly allocated array of element type.
#define NEW_INSTANCE |
( |
|
type | ) |
g_new(type,1) |
- Parameters
-
type | Element type to be allocated. |
- Returns
- A newly allocated space for type
type
.
void array2D_free |
( |
void ** |
arrayPtr | ) |
|
- Parameters
-
arrayPtr | the 2D array to be freed. |
void** array2D_new |
( |
size_t |
row_size, |
|
|
size_t |
col_size, |
|
|
size_t |
element_size, |
|
|
size_t |
pointer_size |
|
) |
| |
Note that NEW_ARRAY2D_INSTANCE() is a more convenient wrapper macro of this function, so call that macro instead.
- Parameters
-
row_size | Number of row. |
col_size | Number of column. |
element_size | Size of one element. |
pointer_size | Size of element pointer. |
- Returns
- A two dimension array of element type.
- See also
- NEW_ARRAY2D_INSTANCE()