Fixes for C++ compilation proposed by Steffan Webb.
This commit is contained in:
parent
f2881c8f2e
commit
f0fd02d42e
@ -135,7 +135,7 @@ cmph_t *bmz_new(cmph_config_t *mph, float c)
|
||||
used_edges = (cmph_uint8 *)malloc(bmz->m/8 + 1);
|
||||
memset(used_edges, 0, bmz->m/8 + 1);
|
||||
free(bmz->g);
|
||||
bmz->g = calloc(bmz->n, sizeof(cmph_uint32));
|
||||
bmz->g = (cmph_uint32 *)calloc(bmz->n, sizeof(cmph_uint32));
|
||||
assert(bmz->g);
|
||||
for (i = 0; i < bmz->n; ++i) // critical nodes
|
||||
{
|
||||
@ -316,7 +316,7 @@ static cmph_uint8 bmz_traverse_critical_nodes_heuristic(bmz_config_data_t *bmz,
|
||||
{
|
||||
if(nunused_g_values == unused_g_values_capacity)
|
||||
{
|
||||
unused_g_values = realloc(unused_g_values, (unused_g_values_capacity + BUFSIZ)*sizeof(cmph_uint32));
|
||||
unused_g_values = (cmph_uint32 *)realloc(unused_g_values, (unused_g_values_capacity + BUFSIZ)*sizeof(cmph_uint32));
|
||||
unused_g_values_capacity += BUFSIZ;
|
||||
}
|
||||
unused_g_values[nunused_g_values++] = next_g;
|
||||
|
@ -142,7 +142,7 @@ cmph_t *bmz8_new(cmph_config_t *mph, float c)
|
||||
used_edges = (cmph_uint8 *)malloc(bmz8->m/8 + 1);
|
||||
memset(used_edges, 0, bmz8->m/8 + 1);
|
||||
free(bmz8->g);
|
||||
bmz8->g = calloc(bmz8->n, sizeof(cmph_uint8));
|
||||
bmz8->g = (cmph_uint32 *)calloc(bmz8->n, sizeof(cmph_uint8));
|
||||
assert(bmz8->g);
|
||||
for (i = 0; i < bmz8->n; ++i) // critical nodes
|
||||
{
|
||||
|
10
src/brz.c
10
src/brz.c
@ -79,12 +79,12 @@ void brz_config_set_tmp_dir(cmph_config_t *mph, cmph_uint8 *tmp_dir)
|
||||
free(brz->tmp_dir);
|
||||
if(tmp_dir[len-1] != '/')
|
||||
{
|
||||
brz->tmp_dir = calloc(len+2, sizeof(cmph_uint8));
|
||||
brz->tmp_dir = (cmph_uint8 *)calloc(len+2, sizeof(cmph_uint8));
|
||||
sprintf((char *)(brz->tmp_dir), "%s/", (char *)tmp_dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
brz->tmp_dir = calloc(len+1, sizeof(cmph_uint8));
|
||||
brz->tmp_dir = (cmph_uint8 *)calloc(len+1, sizeof(cmph_uint8));
|
||||
sprintf((char *)(brz->tmp_dir), "%s", (char *)tmp_dir);
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ cmph_t *brz_new(cmph_config_t *mph, float c)
|
||||
brz->c = c;
|
||||
brz->m = mph->key_source->nkeys;
|
||||
DEBUGP("m: %u\n", brz->m);
|
||||
brz->k = ceil(brz->m/(brz->b));
|
||||
brz->k = ceil(((float)brz->m)/brz->b);
|
||||
DEBUGP("k: %u\n", brz->k);
|
||||
brz->size = (cmph_uint8 *) calloc(brz->k, sizeof(cmph_uint8));
|
||||
|
||||
@ -259,7 +259,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
||||
}
|
||||
nkeys_in_buffer = 0;
|
||||
memory_usage = 0;
|
||||
bzero(buckets_size, brz->k*sizeof(cmph_uint32));
|
||||
memset((void *)buckets_size, 0, brz->k*sizeof(cmph_uint32));
|
||||
nflushes++;
|
||||
free(keys_index);
|
||||
fclose(tmp_fd);
|
||||
@ -318,7 +318,7 @@ static int brz_gen_mphf(cmph_config_t *mph)
|
||||
}
|
||||
nkeys_in_buffer = 0;
|
||||
memory_usage = 0;
|
||||
bzero(buckets_size, brz->k*sizeof(cmph_uint32));
|
||||
memset((void *)buckets_size, 0, brz->k*sizeof(cmph_uint32));
|
||||
nflushes++;
|
||||
free(keys_index);
|
||||
fclose(tmp_fd);
|
||||
|
@ -109,7 +109,7 @@ cmph_t *chm_new(cmph_config_t *mph, float c)
|
||||
visited = (cmph_uint8 *)malloc(chm->n/8 + 1);
|
||||
memset(visited, 0, chm->n/8 + 1);
|
||||
free(chm->g);
|
||||
chm->g = malloc(chm->n * sizeof(cmph_uint32));
|
||||
chm->g = (cmph_uint32 *)malloc(chm->n * sizeof(cmph_uint32));
|
||||
assert(chm->g);
|
||||
for (i = 0; i < chm->n; ++i)
|
||||
{
|
||||
|
@ -112,7 +112,7 @@ static cmph_uint32 count_nlfile_keys(FILE *fd)
|
||||
|
||||
cmph_io_adapter_t *cmph_io_nlfile_adapter(FILE * keys_fd)
|
||||
{
|
||||
cmph_io_adapter_t * key_source = malloc(sizeof(cmph_io_adapter_t));
|
||||
cmph_io_adapter_t * key_source = (cmph_io_adapter_t *)malloc(sizeof(cmph_io_adapter_t));
|
||||
assert(key_source);
|
||||
key_source->data = (void *)keys_fd;
|
||||
key_source->nkeys = count_nlfile_keys(keys_fd);
|
||||
@ -129,7 +129,7 @@ void cmph_io_nlfile_adapter_destroy(cmph_io_adapter_t * key_source)
|
||||
|
||||
cmph_io_adapter_t *cmph_io_nlnkfile_adapter(FILE * keys_fd, cmph_uint32 nkeys)
|
||||
{
|
||||
cmph_io_adapter_t * key_source = malloc(sizeof(cmph_io_adapter_t));
|
||||
cmph_io_adapter_t * key_source = (cmph_io_adapter_t *)malloc(sizeof(cmph_io_adapter_t));
|
||||
assert(key_source);
|
||||
key_source->data = (void *)keys_fd;
|
||||
key_source->nkeys = nkeys;
|
||||
@ -146,8 +146,8 @@ void cmph_io_nlnkfile_adapter_destroy(cmph_io_adapter_t * key_source)
|
||||
|
||||
static cmph_io_adapter_t *cmph_io_vector_new(void * vector, cmph_uint32 nkeys)
|
||||
{
|
||||
cmph_io_adapter_t * key_source = malloc(sizeof(cmph_io_adapter_t));
|
||||
cmph_vector_t * cmph_vector = malloc(sizeof(cmph_vector_t));
|
||||
cmph_io_adapter_t * key_source = (cmph_io_adapter_t *)malloc(sizeof(cmph_io_adapter_t));
|
||||
cmph_vector_t * cmph_vector = (cmph_vector_t *)malloc(sizeof(cmph_vector_t));
|
||||
assert(key_source);
|
||||
assert(cmph_vector);
|
||||
cmph_vector->vector = vector;
|
||||
|
@ -9,7 +9,6 @@ cmph_config_t *__config_new(cmph_io_adapter_t *key_source)
|
||||
{
|
||||
cmph_config_t *mph = (cmph_config_t *)malloc(sizeof(cmph_config_t));
|
||||
memset(mph, 0, sizeof(cmph_config_t));
|
||||
DEBUGP("Creating mph with algorithm %s\n", cmph_names[algo]);
|
||||
if (mph == NULL) return NULL;
|
||||
mph->key_source = key_source;
|
||||
mph->verbosity = 0;
|
||||
|
@ -25,7 +25,7 @@ struct __cmph_t
|
||||
};
|
||||
|
||||
cmph_config_t *__config_new(cmph_io_adapter_t *key_source);
|
||||
void __config_destroy();
|
||||
void __config_destroy(cmph_config_t*);
|
||||
void __cmph_dump(cmph_t *mphf, FILE *);
|
||||
cmph_t *__cmph_load(FILE *f);
|
||||
|
||||
|
@ -77,7 +77,7 @@ void hash_state_dump(hash_state_t *state, char **buf, cmph_uint32 *buflen)
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
*buf = malloc(strlen(cmph_hash_names[state->hashfunc]) + 1 + *buflen);
|
||||
*buf = (char *)malloc(strlen(cmph_hash_names[state->hashfunc]) + 1 + *buflen);
|
||||
memcpy(*buf, cmph_hash_names[state->hashfunc], strlen(cmph_hash_names[state->hashfunc]) + 1);
|
||||
DEBUGP("Algobuf is %u\n", *(cmph_uint32 *)algobuf);
|
||||
memcpy(*buf + strlen(cmph_hash_names[state->hashfunc]) + 1, algobuf, *buflen);
|
||||
|
@ -105,7 +105,7 @@ cmph_t *hashtree_new(cmph_config_t *mph, float c)
|
||||
visited = (char *)malloc(hashtree->n/8 + 1);
|
||||
memset(visited, 0, hashtree->n/8 + 1);
|
||||
free(hashtree->g);
|
||||
hashtree->g = malloc(hashtree->n * sizeof(cmph_uint32));
|
||||
hashtree->g = (cmph_uint32 *)malloc(hashtree->n * sizeof(cmph_uint32));
|
||||
assert(hashtree->g);
|
||||
for (i = 0; i < hashtree->n; ++i)
|
||||
{
|
||||
|
@ -162,7 +162,7 @@ cmph_uint32 jenkins_hash(jenkins_state_t *state, const char *k, cmph_uint32 keyl
|
||||
void jenkins_state_dump(jenkins_state_t *state, char **buf, cmph_uint32 *buflen)
|
||||
{
|
||||
*buflen = sizeof(cmph_uint32);
|
||||
*buf = malloc(*buflen);
|
||||
*buf = (char *)malloc(*buflen);
|
||||
if (!*buf)
|
||||
{
|
||||
*buflen = UINT_MAX;
|
||||
|
Loading…
Reference in New Issue
Block a user