<commit_before>/* $Id$ */

/*
 * Variable-sized bitmaps.  Internally, bitmaps are arrays
 * of chars that are realloc(3)'d to different lengths.
 *
 * This API is not thread-safe!
 */

#ifndef _PFL_VBITMAP_H_
#define _PFL_VBITMAP_H_

#include <sys/types.h>

struct psc_vbitmap {
	unsigned char	*vb_start;
	unsigned char	*vb_end;
	unsigned char	*vb_pos;	/* ptr to current slot for speed */
	int		 vb_lastsize;	/* #ents in last byte, for sizes not multiple of NBBY */
	int		 vb_flags;
};

#define vbitmap psc_vbitmap

/* vbitmap flags */
#define PVBF_AUTO	(1 << 0)	/* auto grow bitmap as necessary */
#define PVBF_STATIC	(1 << 1)	/* vbitmap is statically allocated */
#define PVBF_EXTALLOC	(1 << 2)	/* bitmap mem is externally alloc'd */

#define VBITMAP_INIT_AUTO	{ NULL, NULL, NULL, 0, PVBF_AUTO | PVBF_STATIC }

#define psc_vbitmap_new(siz)	psc_vbitmap_newf((siz), 0)

/**
 * psc_vbitmap_free - reclaim memory from a variable-sized bitmap.
 * @vb: variable bitmap.
 */
#define psc_vbitmap_free(vb)						\
	do {								\
		_psc_vbitmap_free(vb);					\
		(vb) = NULL;						\
	} while (0)

#define psc_vbitmap_set(vb, pos)	((void)psc_vbitmap_setval((vb), (pos), 1))
#define psc_vbitmap_xset(vb, pos)	(psc_vbitmap_setval((vb), (pos), 1) == 0)
#define psc_vbitmap_xsetval(vb, pos, v)	(psc_vbitmap_setval((vb), (pos), (v)) != (v))
#define psc_vbitmap_unset(vb, pos)	((void)psc_vbitmap_setval((vb), (pos), 0))
<commit_msg>add missed psc_vbitmap_nset().  sorry zhihui<commit_after>/* $Id$ */

/*
 * Variable-sized bitmaps.  Internally, bitmaps are arrays
 * of chars that are realloc(3)'d to different lengths.
 *
 * This API is not thread-safe!
 */

#ifndef _PFL_VBITMAP_H_
#define _PFL_VBITMAP_H_

#include <sys/types.h>

struct psc_vbitmap {
	unsigned char	*vb_start;
	unsigned char	*vb_end;
	unsigned char	*vb_pos;	/* ptr to current slot for speed */
	int		 vb_lastsize;	/* #ents in last byte, for sizes not multiple of NBBY */
	int		 vb_flags;
};

#define vbitmap psc_vbitmap

/* vbitmap flags */
#define PVBF_AUTO	(1 << 0)	/* auto grow bitmap as necessary */
#define PVBF_STATIC	(1 << 1)	/* vbitmap is statically allocated */
#define PVBF_EXTALLOC	(1 << 2)	/* bitmap mem is externally alloc'd */

#define VBITMAP_INIT_AUTO	{ NULL, NULL, NULL, 0, PVBF_AUTO | PVBF_STATIC }

#define psc_vbitmap_new(siz)	psc_vbitmap_newf((siz), 0)

/**
 * psc_vbitmap_free - reclaim memory from a variable-sized bitmap.
 * @vb: variable bitmap.
 */
#define psc_vbitmap_free(vb)						\
	do {								\
		_psc_vbitmap_free(vb);					\
		(vb) = NULL;						\
	} while (0)

#define psc_vbitmap_set(vb, pos)	((void)psc_vbitmap_setval((vb), (pos), 1))
#define psc_vbitmap_xset(vb, pos)	(psc_vbitmap_setval((vb), (pos), 1) == 0)
#define psc_vbitmap_xsetval(vb, pos, v)	(psc_vbitmap_setval((vb), (pos), (v)) != (v))
#define psc_vbitmap_unset(vb, pos)	((void)psc_vbitmap_setval((vb), (pos), 0))

#define psc_vbitmap_nset(vb)		(psc_vbitmap_getsize(vb) - psc_vbitmap_nfree(vb))

{'fraction_non_alphanumeric': 0.14232336956521738, 'fraction_numerical': 0.009510869565217392, 'mean_word_length': 4.230905861456483, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2876223', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1251, 'n_words': 300}