Ejemplo n.º 1
0
void
meta0_utils_array_add(GPtrArray *gpa, const guint8 *bytes, const gchar *s)
{
	guint len;
	gchar **v0, **v1;
	guint16 prefix;

	prefix = meta0_utils_bytes_to_prefix(bytes);

	if (!(v0 = gpa->pdata[prefix])) {
		len = 0;
		v1 = g_malloc0(sizeof(gchar*) * 2);
	} else {
		len = g_strv_length(v0);
		v1 = g_realloc(v0, sizeof(gchar*) * (len+2));
	}
	v1[len] = g_strdup(s);
	v1[len+1] = NULL;
	gpa->pdata[prefix] = v1;
}
Ejemplo n.º 2
0
gboolean
meta0_utils_array_replace(GPtrArray *gpa, const guint8 *bytes, const gchar *s, const gchar *d)
{
	guint i, len;
	gchar **v0;
	guint16 prefix;

	prefix = meta0_utils_bytes_to_prefix(bytes);

	if(!(v0 = gpa->pdata[prefix]))
		return FALSE;

	len = g_strv_length(v0);

	for( i=0; i < len ; i++) {
		if ( g_ascii_strncasecmp(v0[i],s, strlen(s))== 0 ) {
			g_free(v0[i]);
			v0[i]=g_strdup(d);
			return TRUE;
		}
	}
	return FALSE;
}
Ejemplo n.º 3
0
static gboolean
_is_treat_prefix(guint8 *cache, const guint8 *prefix)
{
	guint16 slot = meta0_utils_bytes_to_prefix(prefix);
	return cache[ slot / 8 ] & (0x01 << (slot % 8));
}
Ejemplo n.º 4
0
static void
_treat_prefix(guint8 *cache, const guint8 *prefix)
{
	guint16 slot = meta0_utils_bytes_to_prefix(prefix);
	cache[ slot / 8 ] |= (0x01 << (slot % 8));
}