mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
nscd(8): let calloc(3) do the multiplying.
MFC after: 1 week
This commit is contained in:
parent
6613eaa42b
commit
87959e27fd
4 changed files with 14 additions and 16 deletions
|
|
@ -487,8 +487,8 @@ init_cache(struct cache_params const *params)
|
|||
assert(params != NULL);
|
||||
memcpy(&retval->params, params, sizeof(struct cache_params));
|
||||
|
||||
retval->entries = calloc(1,
|
||||
sizeof(*retval->entries) * INITIAL_ENTRIES_CAPACITY);
|
||||
retval->entries = calloc(INITIAL_ENTRIES_CAPACITY,
|
||||
sizeof(*retval->entries));
|
||||
assert(retval->entries != NULL);
|
||||
|
||||
retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
|
||||
|
|
@ -540,8 +540,8 @@ register_cache_entry(struct cache_ *the_cache,
|
|||
|
||||
new_capacity = the_cache->entries_capacity +
|
||||
ENTRIES_CAPACITY_STEP;
|
||||
new_entries = calloc(1,
|
||||
sizeof(*new_entries) * new_capacity);
|
||||
new_entries = calloc(new_capacity,
|
||||
sizeof(*new_entries));
|
||||
assert(new_entries != NULL);
|
||||
|
||||
memcpy(new_entries, the_cache->entries,
|
||||
|
|
@ -582,8 +582,8 @@ register_cache_entry(struct cache_ *the_cache,
|
|||
else
|
||||
policies_size = 2;
|
||||
|
||||
new_common_entry->policies = calloc(1,
|
||||
sizeof(*new_common_entry->policies) * policies_size);
|
||||
new_common_entry->policies = calloc(policies_size,
|
||||
sizeof(*new_common_entry->policies));
|
||||
assert(new_common_entry->policies != NULL);
|
||||
|
||||
new_common_entry->policies_size = policies_size;
|
||||
|
|
|
|||
|
|
@ -274,9 +274,8 @@ add_configuration_entry(struct configuration *config,
|
|||
struct configuration_entry **new_entries;
|
||||
|
||||
config->entries_capacity *= 2;
|
||||
new_entries = calloc(1,
|
||||
sizeof(*new_entries) *
|
||||
config->entries_capacity);
|
||||
new_entries = calloc(config->entries_capacity,
|
||||
sizeof(*new_entries));
|
||||
assert(new_entries != NULL);
|
||||
memcpy(new_entries, config->entries,
|
||||
sizeof(struct configuration_entry *) *
|
||||
|
|
@ -522,9 +521,8 @@ init_configuration(void)
|
|||
assert(retval != NULL);
|
||||
|
||||
retval->entries_capacity = INITIAL_ENTRIES_CAPACITY;
|
||||
retval->entries = calloc(1,
|
||||
sizeof(*retval->entries) *
|
||||
retval->entries_capacity);
|
||||
retval->entries = calloc(retval->entries_capacity,
|
||||
sizeof(*retval->entries));
|
||||
assert(retval->entries != NULL);
|
||||
|
||||
pthread_rwlock_init(&retval->rwlock, NULL);
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ typedef unsigned int hashtable_index_t;
|
|||
#define HASHTABLE_INIT(table, type, field, _entries_size) \
|
||||
do { \
|
||||
hashtable_index_t var; \
|
||||
(table)->entries = calloc(1, \
|
||||
sizeof(*(table)->entries) * (_entries_size)); \
|
||||
(table)->entries = calloc(_entries_size, \
|
||||
sizeof(*(table)->entries)); \
|
||||
(table)->entries_size = (_entries_size); \
|
||||
for (var = 0; var < HASHTABLE_ENTRIES_COUNT(table); ++var) {\
|
||||
(table)->entries[var].field.capacity = \
|
||||
|
|
|
|||
|
|
@ -828,8 +828,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
if (s_configuration->threads_num > 1) {
|
||||
threads = calloc(1, sizeof(*threads) *
|
||||
s_configuration->threads_num);
|
||||
threads = calloc(s_configuration->threads_num,
|
||||
sizeof(*threads));
|
||||
for (i = 0; i < s_configuration->threads_num; ++i) {
|
||||
thread_args = malloc(
|
||||
sizeof(*thread_args));
|
||||
|
|
|
|||
Loading…
Reference in a new issue