+ * pids_list_to_array
+ *
+ * DESCRIPTION
+ * Copies element from list to array. Assumes the space for the array is
+ * allocated.
+ *
+ * PARAMETERS
+ * `array' First element of target array
+ * `list' Head of the list
+ * `array_length' Length (element count) of the target array
+ */
+static void pids_list_to_array(pid_t *array, pids_list_t *list,
+ const size_t array_length) {
+
+ assert(list);
+ assert(array);
+ assert(array_length > 0);
+
+ size_t current = 0;
+
+ while (list != NULL && current < array_length) {
+ array[current] = list->pid;
+ list = list->next;
+ ++current;
+ }
+}
+
+/*
+ * NAME
+ * initialize_proc_pids
+ *
+ * DESCRIPTION
+ * Helper function to properly initialize array of proc_pids.
+ * Allocates memory for proc_pids structs.
+ *
+ * PARAMETERS
+ * `procs_names_array' Array of null-terminated strings with
+ * process' names to be copied to new array
+ * `procs_names_array_size' procs_names_array element count
+ * `proc_pids_array' Address of pointer, under which new
+ * array of proc_pids will be allocated.
+ * Must be NULL.
+ * RETURN VALUE
+ * 0 on success. Negative number on error:
+ * -1: allocation error
+ */
+static int initialize_proc_pids(const char **procs_names_array,
+ const size_t procs_names_array_size,
+ proc_pids_t **proc_pids_array) {
+
+ assert(proc_pids_array);
+ assert(NULL == *proc_pids_array);
+
+ /* Copy procs names to output array. Initialize pids list with NULL value. */
+ *proc_pids_array = calloc(procs_names_array_size, sizeof(**proc_pids_array));
+
+ if (NULL == *proc_pids_array)
+ return -1;
+
+ for (size_t i = 0; i < procs_names_array_size; ++i) {
+ sstrncpy((*proc_pids_array)[i].proccess_name, procs_names_array[i],
+ STATIC_ARRAY_SIZE((*proc_pids_array)[i].proccess_name));
+ (*proc_pids_array)[i].pids = NULL;
+ }
+
+ return 0;
+}
+
+/*
+ * NAME