9 void list_print(struct mail_list
*lst
)
17 for (n
= 0; n
< lst
->n
; n
++) {
18 for (i
= 0; i
< 16; i
++) {
19 fprintf(stderr
, "%02x", lst
->list
[n
].addr_md5
[i
]);
21 fprintf(stderr
, "[%u] %s -- %s -- %s\n",
30 * Allocate a list via malloc of n_elem elements
32 * @param[in|out] n_elem number of elements in the list
33 * @param[in] limit max number of elements
35 * @retval Pointer to the new allocated list or NULL on error
37 struct mail_list
*list_create(size_t n_elem
, size_t limit
)
39 struct mail_list
*lst
;
47 lst
= malloc(sizeof(struct mail_list
) + n_elem
* sizeof(struct mail_entry
));
49 fprintf(stderr
, "%s - MALLOC: %s", __func__
, strerror(errno
));
53 fprintf(stderr
, "%s - MALLOC: item %lu [%lu]\n", __func__
,
54 (unsigned long) n_elem
,
55 (unsigned long) (sizeof(struct mail_list
) + n_elem
* sizeof(struct mail_entry
)));
63 void list_free(struct mail_list
*lst
)
68 fprintf(stderr
, "%s - FREE: list\n", __func__
);
72 int list_add_entry(struct mail_list
*lst
, struct mail_entry
*entry
)
76 if (lst
->nfree
< MESSAGE_LIMIT
) {
79 memcpy(&lst
->list
[n
], entry
, sizeof(struct mail_entry
));
81 /* Update 1st free slot index */