Code Search for Developers
 
 
  

dict.c from TextIndexNG at Krugle


Show dict.c syntax highlighted

/*
 * dict.c
 *
 * Implementation of generic dictionary routines.
 * Copyright (C) 2001 Farooq Mela.
 *
 * $Id: dict.c 1451 2006-01-13 11:49:57Z ajung $
 */

#include <stdlib.h>

#include "dict.h"
#include "dict_private.h"

dict_malloc_func _dict_malloc = malloc;
dict_free_func _dict_free = free;

dict_malloc_func
dict_set_malloc(func)
	dict_malloc_func func;
{
	dict_malloc_func old = _dict_malloc;
	_dict_malloc = func ? func : malloc;
	return old;
}

dict_free_func
dict_set_free(func)
	dict_free_func func;
{
	dict_free_func old = _dict_free;
	_dict_free = func ? func : free;
	return old;
}

int
_dict_key_cmp(p1, p2)
	const void	*p1;
	const void	*p2;
{
	/*
	 * We cannot simply subtract pointers because that might result in signed
	 * overflow.
	 */
	return (p1 > p2) - (p1 < p2);
}

void
dict_destroy(dct, del)
	dict	*dct;
	int		 del;
{
	ASSERT(dct != NULL);

	dct->_destroy(dct->_object, del);
	FREE(dct);
}

void
dict_itor_destroy(itor)
	dict_itor *itor;
{
	ASSERT(itor != NULL);

	itor->_destroy(itor->_itor);
	FREE(itor);
}




See more files for this project here

TextIndexNG

The next generation fulltext index for the Zope Catalog\r\n\r\nFor details see http://www.zope.org/Members/ajung/TextIndexNG/wiki/TextIndexNG\r\n\r\n

Project homepage: http://sourceforge.net/projects/textindexng
Programming language(s): C,Python
License: other

  tests/
    __init__.py
    testTXNGSplitter.py
  LICENSE
  __init__.py
  dict.c
  dict.h
  dict_private.h
  hashtable.c
  hashtable.h
  splitter.c