libdebian-installer
Macros | Functions
Di_mem

Macros

#define di_new(struct_type, n_structs)   ((struct_type *) di_malloc (sizeof (struct_type) * (n_structs)))
 
#define di_new0(struct_type, n_structs)   ((struct_type *) di_malloc0 (sizeof (struct_type) * (n_structs)))
 
#define di_renew(struct_type, mem, n_structs)   ((struct_type *) di_realloc ((mem), sizeof (struct_type) * (n_structs)))
 

Functions

void * di_malloc (size_t n_bytes) __attribute__((malloc))
 
void * di_malloc0 (size_t n_bytes) __attribute__((malloc))
 
void * di_realloc (void *mem, size_t n_bytes) __attribute__((malloc))
 
void di_free (void *mem)
 

Detailed Description

Macro Definition Documentation

#define di_new (   struct_type,
  n_structs 
)    ((struct_type *) di_malloc (sizeof (struct_type) * (n_structs)))
#define di_new0 (   struct_type,
  n_structs 
)    ((struct_type *) di_malloc0 (sizeof (struct_type) * (n_structs)))
Parameters
struct_typereturned type
n_structsnumber of returned structs

Referenced by di_hash_table_size(), di_list_alloc(), di_packages_alloc(), di_release_alloc(), di_slist_alloc(), and internal_di_packages_allocator_alloc().

#define di_renew (   struct_type,
  mem,
  n_structs 
)    ((struct_type *) di_realloc ((mem), sizeof (struct_type) * (n_structs)))
Parameters
struct_typereturned type
memcurrent memory pointer
n_structsnumber of returned structs

Referenced by di_package_parser_info().

Function Documentation

void di_free ( void *  mem)
void* di_malloc ( size_t  n_bytes)

Allocate memory

Parameters
n_bytessize in bytes
Postcondition
never returns NULL

References di_error.

Referenced by di_mem_chunk_alloc(), and di_package_parser_info().

30 {
31  void *mem;
32 
33  mem = malloc (n_bytes);
34 
35  if (!mem)
36  di_error ("%s: failed to allocate %zu bytes", DI_STRLOC, n_bytes);
37  return mem;
38 }
#define di_error(format...)
Definition: log.h:55
void* di_malloc0 ( size_t  n_bytes)

Allocate cleared memory

Parameters
n_bytessize in bytes
Postcondition
never returns NULL

References di_error.

41 {
42  void *mem;
43 
44  mem = calloc (1, n_bytes);
45 
46  if (!mem)
47  di_error ("%s: failed to allocate %zu bytes", DI_STRLOC, n_bytes);
48  return mem;
49 }
#define di_error(format...)
Definition: log.h:55
void* di_realloc ( void *  mem,
size_t  n_bytes 
)

Reallocate memory

Parameters
memmemory
n_bytessize in bytes
Postcondition
never returns NULL

References di_error.

52 {
53  mem = realloc (mem, n_bytes);
54 
55  if (!mem)
56  di_error ("%s: failed to allocate %zu bytes", DI_STRLOC, n_bytes);
57  return mem;
58 }
#define di_error(format...)
Definition: log.h:55