X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fq.h;h=0e9d60212b2126fbbce0b6bf8c992dff45fb8a63;hb=efc92c191c8417ab626b0e8e639f8d516e4000ff;hp=b53044736d5bb5719dd9ea7771ff1252d8e03e9d;hpb=7729deb8d1fe947c8d0af89cb5368c7e0f8e7990;p=swftools.git diff --git a/lib/q.h b/lib/q.h index b530447..0e9d602 100644 --- a/lib/q.h +++ b/lib/q.h @@ -3,14 +3,31 @@ Part of the swftools package. - Copyright (c) 2001 Matthias Kramm - - This file is distributed under the GPL, see file COPYING for details */ + Copyright (c) 2001,2002,2003,2004 Matthias Kramm + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef __q_h__ #define __q_h__ #include +#include "../config.h" + +#ifdef __cplusplus +extern "C" { +#endif /* dynamically growing mem section */ typedef struct _mem_t { @@ -19,6 +36,7 @@ typedef struct _mem_t { int pos; } mem_t; +/* fifo buffered growing mem region */ typedef struct _ringbuffer_t { void*internal; @@ -47,6 +65,17 @@ typedef struct _stringarray_t void*internal; } stringarray_t; +/* heap */ +typedef struct _heap +{ + void**elements; + char*data; + int elem_size; + int size; + int max_size; + int(*compare)(const void *, const void *); +} heap_t; + void mem_init(mem_t*mem); int mem_put(mem_t*m, void*data, int length); int mem_putstring(mem_t*m, string_t str); @@ -88,14 +117,19 @@ void dictionary_del(dictionary_t*dict, const char* name); void dictionary_clear(dictionary_t*dict); void dictionary_destroy(dictionary_t*dict); -char* strndup(const char*str, int size); +void heap_init(heap_t*h,int n,int elem_size, int(*compare)(const void *, const void *)); +void heap_clear(heap_t*h); +void heap_put(heap_t*h, void*e); +int heap_size(heap_t*h); +void* heap_max(heap_t*h); +void* heap_chopmax(heap_t*h); +void heap_dump(heap_t*h, FILE*fi); +void** heap_flatten(heap_t*h); -void* qmalloc_internal(int len); -void* qrealloc_internal(void*old, int len); -void qfree_internal(void*old); +char* strdup_n(const char*str, int size); -#define qmalloc(len) qmalloc_internal(len) -#define qrealloc(old, len) qmalloc_internal(old, len) -#define qfree(old) qmalloc_internal(old) +#ifdef __cplusplus +} +#endif #endif //__q_h__