Displaying 2 results from an estimated 2 matches for "glthread_lock_".
2018 Feb 10
0
Re: [PATCH] Add a cache for iconv_t handles to hive_t
...d W.M. Jones:
>
> >> +threadlib
> >> '
> >
> > Probably better to keep these sorted.
>
> When I rebuilt from scratch, it turned out that threadlib was not
> enough. Using the "lock" module with the gl_lock_{init,lock,unlock}
> instead of glthread_lock_{init,lock,unlock} as described in lock.h seems
> correct, though. I have pushed that change.
>
> > I wonder if there's a way we can avoid hard-coding ‘4’ here, which
> > AIUI is the size of the enum type. Maybe adding an extra enum case
> > ‘nr_recode_types’?
>
>...
2018 Feb 09
2
[PATCH] Add a cache for iconv_t handles to hive_t
...;
+#include <iconv.h>
+#include <glthread/lock.h>
#ifdef HAVE_MMAP
#include <sys/mman.h>
@@ -62,6 +64,32 @@ header_checksum (const hive_h *h)
#define HIVEX_OPEN_MSGLVL_MASK (HIVEX_OPEN_VERBOSE|HIVEX_OPEN_DEBUG)
+iconv_t *
+_hivex_get_iconv (hive_h *h, recode_type t)
+{
+ glthread_lock_lock (&h->iconv_cache[t].mutex);
+ if (h->iconv_cache[t].handle == NULL) {
+ if (t == utf8_to_latin1)
+ h->iconv_cache[t].handle = iconv_open ("LATIN1", "UTF-8");
+ else if (t == latin1_to_utf8)
+ h->iconv_cache[t].handle = iconv_open ("UTF-8...