2013-10-29 15:02:21 -05:00
|
|
|
/**
|
|
|
|
*
|
2014-01-28 08:30:01 -06:00
|
|
|
* \file list.h
|
|
|
|
* @brief getdns list management functions
|
2013-10-29 15:02:21 -05:00
|
|
|
*
|
|
|
|
* Originally taken from the getdns API description pseudo implementation.
|
|
|
|
*
|
|
|
|
*/
|
2014-01-28 08:30:01 -06:00
|
|
|
|
|
|
|
/*
|
2014-02-25 07:12:33 -06:00
|
|
|
* Copyright (c) 2013, NLnet Labs, Verisign, Inc.
|
2014-01-28 08:30:01 -06:00
|
|
|
* All rights reserved.
|
2013-10-29 15:02:21 -05:00
|
|
|
*
|
2014-01-28 08:30:01 -06:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2014-02-25 07:23:19 -06:00
|
|
|
* * Neither the names of the copyright holders nor the
|
2014-01-28 08:30:01 -06:00
|
|
|
* names of its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2013-10-29 15:02:21 -05:00
|
|
|
*
|
2014-01-28 08:30:01 -06:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2013-10-29 15:02:21 -05:00
|
|
|
*/
|
2014-01-28 08:30:01 -06:00
|
|
|
|
2013-10-29 15:02:21 -05:00
|
|
|
#ifndef _GETDNS_LIST_H_
|
|
|
|
#define _GETDNS_LIST_H_
|
|
|
|
|
2014-05-19 08:50:34 -05:00
|
|
|
#include "getdns/getdns.h"
|
2013-12-08 15:56:34 -06:00
|
|
|
#include "types-internal.h"
|
2013-10-29 15:02:21 -05:00
|
|
|
|
|
|
|
#define GETDNS_LIST_BLOCKSZ 10
|
|
|
|
|
|
|
|
/**
|
|
|
|
* getdns list data type
|
|
|
|
* Use helper functions getdns_list_* to manipulate and iterate lists
|
|
|
|
* lists are implemented as arrays internally since the helper functions
|
|
|
|
* like to reference indexes in the list. Elements are allocated in blocks
|
|
|
|
* and then marked valid as they are used and invalid as they are not used
|
|
|
|
* The use cases do not justify working too hard at shrinking the structures.
|
|
|
|
* Indexes are 0 based.
|
|
|
|
*/
|
2013-11-05 14:03:44 -06:00
|
|
|
struct getdns_list
|
|
|
|
{
|
2013-12-09 09:26:18 -06:00
|
|
|
size_t numalloc;
|
|
|
|
size_t numinuse;
|
2015-09-30 09:05:19 -05:00
|
|
|
struct getdns_item *items;
|
2013-12-08 17:05:18 -06:00
|
|
|
struct mem_funcs mf;
|
2013-11-03 18:08:28 -06:00
|
|
|
};
|
2013-10-29 15:02:21 -05:00
|
|
|
|
2015-07-08 06:07:24 -05:00
|
|
|
inline static getdns_list *_getdns_list_create_with_mf(struct mem_funcs *mf)
|
2015-06-30 07:43:52 -05:00
|
|
|
{ return getdns_list_create_with_extended_memory_functions(
|
|
|
|
mf->mf_arg, mf->mf.ext.malloc, mf->mf.ext.realloc, mf->mf.ext.free); }
|
|
|
|
|
2013-10-29 15:02:21 -05:00
|
|
|
#endif
|
2014-01-28 08:30:01 -06:00
|
|
|
|
|
|
|
/* list.h */
|