#include "list.h"
#include "mountP.h"
-#define MNT_OL_MAXMAPS 64
+#define MNT_OL_MAXMAPS 8
enum libmnt_optsrc {
MNT_OPTSRC_STRING,
static void reset_cache(struct optlist_cache *cache)
{
- if (!cache)
+ if (!cache || (cache->flags_ready == 0 && cache->optstr_ready == 0))
return;
free(cache->optstr);
memset(cache, 0, sizeof(*cache));
return (size_t) -1;
}
-static void optlist_cleanup_cache(struct libmnt_optlist *ls, const struct libmnt_optmap *map)
+static void optlist_cleanup_cache(struct libmnt_optlist *ls)
{
size_t i;
if (list_empty(&ls->opts))
return;
- if (map) {
- size_t idx = optlist_get_mapidx(ls, map);
-
- if (idx == (size_t) -1)
- return;
-
- reset_cache(&ls->cache_mapped[idx]);
- }
+ for (i = 0; i < ARRAY_SIZE(ls->cache_mapped); i++)
+ reset_cache(&ls->cache_mapped[i]);
for (i = 0; i < __MNT_OL_FLTR_COUNT; i++)
reset_cache(&ls->cache_all[i]);
ls->is_recursive = 0;
}
- optlist_cleanup_cache(ls, opt->map);
+ optlist_cleanup_cache(ls);
list_del_init(&opt->opts);
free(opt->value);
opt->src = MNT_OPTSRC_STRING;
}
- optlist_cleanup_cache(ls, map);
+ optlist_cleanup_cache(ls);
return 0;
}
opt->src = MNT_OPTSRC_FLAG;
}
- optlist_cleanup_cache(ls, map);
+ optlist_cleanup_cache(ls);
return 0;
}