view tern.h @ 724:2174f92c5f9b

Fix bug in vdp_next_hint that was causing HINTs to fire repeatedly when they should not have fired at all based on an HINT interval that was larger than the number of active lines in the display
author Michael Pavone <pavone@retrodev.com>
date Fri, 22 May 2015 18:38:44 -0700
parents de6f00204fa2
children 1b2f8280ba81
line wrap: on
line source

/*
 Copyright 2013 Michael Pavone
 This file is part of BlastEm.
 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
*/
#ifndef TERN_H_
#define TERN_H_

#include <stdint.h>

#define MAX_INT_KEY_SIZE (sizeof(uint32_t) + 2)

typedef union {
	void     *ptrval;
	intptr_t intval;
} tern_val;

typedef struct tern_node {
	struct tern_node *left;
	union {
		struct tern_node *next;
		tern_val         value;
	} straight;
	struct tern_node *right;
	char             el;
} tern_node;

tern_node * tern_insert(tern_node * head, char * key, tern_val value);
int tern_find(tern_node * head, char * key, tern_val *ret);
tern_node * tern_find_prefix(tern_node * head, char * key);
intptr_t tern_find_int(tern_node * head, char * key, intptr_t def);
tern_node * tern_insert_int(tern_node * head, char * key, intptr_t value);
void * tern_find_ptr_default(tern_node * head, char * key, void * def);
void * tern_find_ptr(tern_node * head, char * key);
tern_node * tern_insert_ptr(tern_node * head, char * key, void * value);
char * tern_int_key(uint32_t key, char * buf);

#endif //TERN_H_