b0563a493c
* Add support for Maxmind GeoIP2 database files (#913). * Copy/paste error. * Mark GeoipCode3 as deprecated. * Fix build when compiling with AMBuild. * Replace loose libmaxminddb files with submodule. * Fix Linux build. * One more hack for submodule. * Actually fix Linux build. * GeoIP2 extension to sourcemod * Update basevotes When a player leaves during a voteban, he will be banned anyway. Also added a cvar with a ban time setting. * Update basevotes.sp * Update AMBuilder * ke::AString to std::string * Update extension.cpp * Update AMBuilder * Added coordination natives Added GeoipLatitude, GeoipLongitude, GeoipDistance natives. * Create osdefs.h * Update maxminddb_config.h * Update extension.cpp * Update extension.cpp * Added automatic search for database file * Fix automatic search for database file * Update extension.cpp * Update geoip.inc * .gitmodules revert * Update geoip.inc * Update libmaxminddb to version 1.5.2 * Update extension.cpp * Check language in the DB * Removed langCount variable * Determination of the client's language * Update geoip.inc * Update geoip.inc * Update extension.cpp * Update geoip.inc * Update extension.cpp * space instead of tab in .inc * Update extension.cpp * Update geoip.inc * Optimizing length measurement region code * Update package script to fetch the new GeoLite2 database This package is the last CC-BY-SA licensed GeoLite2-City database extracted from https://src.fedoraproject.org/rpms/geolite2 from december 2019. This doubles the download size for SM packages, but it's what we have to deal with atm :( * Fix potentially returning uninitialized memory in GeoipRegionCode If the lookup failed, we'd copy back whatever is on the stack in the ccode buffer. Co-authored-by: Nick Hastings <nshastings@gmail.com> Co-authored-by: Headline <michaelwflaherty@me.com> Co-authored-by: Accelerator74 <dmitry@447751-accele74.tmweb.ru> Co-authored-by: Peace-Maker <peace-maker@wcfan.de>
53 lines
1.7 KiB
C++
53 lines
1.7 KiB
C++
#ifndef DATA_POOL_H
|
|
#define DATA_POOL_H
|
|
|
|
#include "maxminddb.h"
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
// This should be large enough that we never need to grow the array of pointers
|
|
// to blocks. 32 is enough. Even starting out of with size 1 (1 struct), the
|
|
// 32nd element alone will provide 2**32 structs as we exponentially increase
|
|
// the number in each block. Being confident that we do not have to grow the
|
|
// array lets us avoid writing code to do that. That code would be risky as it
|
|
// would rarely be hit and likely not be well tested.
|
|
#define DATA_POOL_NUM_BLOCKS 32
|
|
|
|
// A pool of memory for MMDB_entry_data_list_s structs. This is so we can
|
|
// allocate multiple up front rather than one at a time for performance
|
|
// reasons.
|
|
//
|
|
// The order you add elements to it (by calling data_pool_alloc()) ends up as
|
|
// the order of the list.
|
|
//
|
|
// The memory only grows. There is no support for releasing an element you take
|
|
// back to the pool.
|
|
typedef struct MMDB_data_pool_s {
|
|
// Index of the current block we're allocating out of.
|
|
size_t index;
|
|
|
|
// The size of the current block, counting by structs.
|
|
size_t size;
|
|
|
|
// How many used in the current block, counting by structs.
|
|
size_t used;
|
|
|
|
// The current block we're allocating out of.
|
|
MMDB_entry_data_list_s *block;
|
|
|
|
// The size of each block.
|
|
size_t sizes[DATA_POOL_NUM_BLOCKS];
|
|
|
|
// An array of pointers to blocks of memory holding space for list
|
|
// elements.
|
|
MMDB_entry_data_list_s *blocks[DATA_POOL_NUM_BLOCKS];
|
|
} MMDB_data_pool_s;
|
|
|
|
MMDB_data_pool_s *data_pool_new(size_t const);
|
|
void data_pool_destroy(MMDB_data_pool_s *const);
|
|
MMDB_entry_data_list_s *data_pool_alloc(MMDB_data_pool_s *const);
|
|
MMDB_entry_data_list_s *data_pool_to_list(MMDB_data_pool_s *const);
|
|
|
|
#endif
|