forked from github/server
remove cvector.[hc] completely
This commit is contained in:
parent
de13d0d412
commit
42eb0ef0ed
7 changed files with 0 additions and 170 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <util/attrib.c>
|
#include <util/attrib.c>
|
||||||
#include <util/base36.c>
|
#include <util/base36.c>
|
||||||
#include <util/crmessage.c>
|
#include <util/crmessage.c>
|
||||||
#include <util/cvector.c>
|
|
||||||
#include <util/dice.c>
|
#include <util/dice.c>
|
||||||
#include <util/event.c>
|
#include <util/event.c>
|
||||||
#include <util/eventbus.c>
|
#include <util/eventbus.c>
|
||||||
|
|
|
@ -56,7 +56,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
#include <util/bsdstring.h>
|
||||||
#include <util/cvector.h>
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
#include <util/os.h>
|
#include <util/os.h>
|
||||||
|
|
|
@ -22,8 +22,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <util/cvector.h>
|
|
||||||
|
|
||||||
#define SHOW_KILLS
|
#define SHOW_KILLS
|
||||||
#undef SMALL_BATTLE_MESSAGES
|
#undef SMALL_BATTLE_MESSAGES
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,6 @@
|
||||||
<ClInclude Include="util\bsdstring.h" />
|
<ClInclude Include="util\bsdstring.h" />
|
||||||
<ClInclude Include="util\console.h" />
|
<ClInclude Include="util\console.h" />
|
||||||
<ClInclude Include="util\crmessage.h" />
|
<ClInclude Include="util\crmessage.h" />
|
||||||
<ClInclude Include="util\cvector.h" />
|
|
||||||
<ClInclude Include="util\event.h" />
|
<ClInclude Include="util\event.h" />
|
||||||
<ClInclude Include="util\eventbus.h" />
|
<ClInclude Include="util\eventbus.h" />
|
||||||
<ClInclude Include="util\filereader.h" />
|
<ClInclude Include="util\filereader.h" />
|
||||||
|
@ -127,7 +126,6 @@
|
||||||
<ClCompile Include="util\bsdstring.c" />
|
<ClCompile Include="util\bsdstring.c" />
|
||||||
<ClCompile Include="util\console.c" />
|
<ClCompile Include="util\console.c" />
|
||||||
<ClCompile Include="util\crmessage.c" />
|
<ClCompile Include="util\crmessage.c" />
|
||||||
<ClCompile Include="util\cvector.c" />
|
|
||||||
<ClCompile Include="util\dice.c" />
|
<ClCompile Include="util\dice.c" />
|
||||||
<ClCompile Include="util\event.c" />
|
<ClCompile Include="util\event.c" />
|
||||||
<ClCompile Include="util\eventbus.c" />
|
<ClCompile Include="util\eventbus.c" />
|
||||||
|
|
|
@ -26,9 +26,6 @@
|
||||||
<ClInclude Include="util\crmessage.h">
|
<ClInclude Include="util\crmessage.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="util\cvector.h">
|
|
||||||
<Filter>Header Files</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="util\event.h">
|
<ClInclude Include="util\event.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -127,9 +124,6 @@
|
||||||
<ClCompile Include="util\crmessage.c">
|
<ClCompile Include="util\crmessage.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="util\cvector.c">
|
|
||||||
<Filter>Source Files</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="util\dice.c">
|
<ClCompile Include="util\dice.c">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -1,97 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#include <platform.h>
|
|
||||||
#include "cvector.h"
|
|
||||||
#include "rng.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <memory.h>
|
|
||||||
|
|
||||||
void
|
|
||||||
cv_init(cvector * cv)
|
|
||||||
{
|
|
||||||
cv->begin = 0;
|
|
||||||
cv->end = 0;
|
|
||||||
cv->space = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
cvector *
|
|
||||||
cv_kill(cvector * cv)
|
|
||||||
{
|
|
||||||
if (cv->begin) free(cv->begin);
|
|
||||||
cv_init(cv);
|
|
||||||
return cv;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
cv_size(cvector * cv)
|
|
||||||
{
|
|
||||||
return cv->end - cv->begin;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cv_reserve(cvector * cv, size_t size)
|
|
||||||
{
|
|
||||||
size_t count = cv->end - cv->begin;
|
|
||||||
cv->begin = realloc(cv->begin, size * sizeof(void *));
|
|
||||||
|
|
||||||
cv->space = size;
|
|
||||||
cv->end = cv->begin + count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
cv_pushback(cvector * cv, void *u)
|
|
||||||
{
|
|
||||||
if (cv->space == cv_size(cv))
|
|
||||||
cv_reserve(cv, cv->space ? cv->space * 2 : 2);
|
|
||||||
*(cv->end++) = u;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
__cv_scramblecmp(const void *p1, const void *p2)
|
|
||||||
{
|
|
||||||
return *((long *) p1) - *((long *) p2);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define addptr(p,i) ((void *)(((char *)p) + i))
|
|
||||||
|
|
||||||
/** randomly shuffle an array
|
|
||||||
* for correctness, see Donald E. Knuth, The Art of Computer Programming
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
__cv_scramble(void *v1, size_t n, size_t width)
|
|
||||||
{
|
|
||||||
size_t i;
|
|
||||||
void * temp = malloc(width);
|
|
||||||
for (i=0;i!=n;++i) {
|
|
||||||
size_t j = i + (rng_int() % (n-i));
|
|
||||||
memcpy(temp, addptr(v1, i*width), width);
|
|
||||||
memcpy(addptr(v1, i*width), addptr(v1, j*width), width);
|
|
||||||
memcpy(addptr(v1, j*width), temp, width);
|
|
||||||
}
|
|
||||||
free(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
v_scramble(void **begin, void **end)
|
|
||||||
{
|
|
||||||
__cv_scramble(begin, end - begin, sizeof(void *));
|
|
||||||
}
|
|
|
@ -1,61 +0,0 @@
|
||||||
/*
|
|
||||||
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
|
|
||||||
Katja Zedel <katze@felidae.kn-bremen.de
|
|
||||||
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted, provided that the above
|
|
||||||
copyright notice and this permission notice appear in all copies.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
||||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
||||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
||||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
||||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
||||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
||||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
**/
|
|
||||||
|
|
||||||
#ifndef CVECTOR_H
|
|
||||||
#define CVECTOR_H
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef WIN32
|
|
||||||
#ifndef __cdecl
|
|
||||||
#define __cdecl
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
typedef struct cvector cvector;
|
|
||||||
|
|
||||||
struct cvector {
|
|
||||||
void **begin;
|
|
||||||
void **end;
|
|
||||||
size_t space;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef int (__cdecl * v_sort_fun) (const void *, const void *);
|
|
||||||
|
|
||||||
void cv_init(cvector * cv);
|
|
||||||
cvector *cv_kill(cvector * cv);
|
|
||||||
size_t cv_size(cvector * cv);
|
|
||||||
void cv_reserve(cvector * cv, size_t size);
|
|
||||||
void cv_pushback(cvector * cv, void *u);
|
|
||||||
void v_scramble(void **begin, void **end);
|
|
||||||
|
|
||||||
#define cv_remove(c, i) { void** x = v_find((c)->begin, (c)->end, (i)); if (x) { *x = *(c)->end; (c)->end--; } }
|
|
||||||
#define cv_foreach(item, vector) \
|
|
||||||
{ \
|
|
||||||
void **iterator; \
|
|
||||||
for (iterator = (vector).begin; iterator<(vector).end; ++iterator) \
|
|
||||||
{ \
|
|
||||||
(item) = *iterator;
|
|
||||||
#define cv_next(item) } }
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
Loading…
Reference in a new issue