+/** Adds entry to the cache */
+int CacheAdd (module_cache_t ***cache, size_t *count,
+ const char *path, const struct stat *st, module_t *module)
+{
+ module_cache_t **entries;
+
+ entries = realloc (*cache, (*count + 1) * sizeof (*entries));
+ if (unlikely(entries == NULL))
+ return -1;
+ *cache = entries;
+
+ entries[*count] = malloc (sizeof (**entries));
+ if (unlikely(entries[*count] == NULL))
+ return -1;
+ /* NOTE: strdup() could be avoided, but it would be a bit ugly */
+ entries[*count]->path = strdup (path);
+ entries[*count]->mtime = st->st_mtime;
+ entries[*count]->size = st->st_size;
+ entries[*count]->p_module = module;
+ (*count)++;
+ return 0;
+}
+