summaryrefslogtreecommitdiff
path: root/girepository/cmph/chd_ph.c
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2012-08-10 11:43:02 +0800
committerColin Walters <walters@verbum.org>2012-10-27 12:06:09 -0400
commiteccd4e379ac345cbf6f67b8b764491bf8e756e10 (patch)
treef46f93ab6750275079ce777583fbccb0b63e7ca1 /girepository/cmph/chd_ph.c
parent04d10dce6f2d1d7ddb4ec9b3ecd5ef21abda2851 (diff)
downloadgobject-introspection-eccd4e379ac345cbf6f67b8b764491bf8e756e10.tar.gz
cmph: Remove C99ism and other fixes
...So that it will compile on non-C99 compilers. The changes are mainly moving the variable declarations to the start of the resecptive blocks. Also, replace the use of buflen in chd.c as it might not be defined for all platforms, instead using packed_cr_size as it seems to represent the value that is to be printed/displayed by the debugging output. https://bugzilla.gnome.org/show_bug.cgi?id=681820
Diffstat (limited to 'girepository/cmph/chd_ph.c')
-rw-r--r--girepository/cmph/chd_ph.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/girepository/cmph/chd_ph.c b/girepository/cmph/chd_ph.c
index 6cd9437a..8356bded 100644
--- a/girepository/cmph/chd_ph.c
+++ b/girepository/cmph/chd_ph.c
@@ -193,8 +193,9 @@ void chd_ph_config_set_hashfuncs(cmph_config_t *mph, CMPH_HASH *hashfuncs)
void chd_ph_config_set_b(cmph_config_t *mph, cmph_uint32 keys_per_bucket)
{
+ chd_ph_config_data_t *chd_ph;
assert(mph);
- chd_ph_config_data_t *chd_ph = (chd_ph_config_data_t *)mph->data;
+ chd_ph = (chd_ph_config_data_t *)mph->data;
if(keys_per_bucket < 1 || keys_per_bucket >= 15)
{
keys_per_bucket = 4;
@@ -205,8 +206,9 @@ void chd_ph_config_set_b(cmph_config_t *mph, cmph_uint32 keys_per_bucket)
void chd_ph_config_set_keys_per_bin(cmph_config_t *mph, cmph_uint32 keys_per_bin)
{
+ chd_ph_config_data_t *chd_ph;
assert(mph);
- chd_ph_config_data_t *chd_ph = (chd_ph_config_data_t *)mph->data;
+ chd_ph = (chd_ph_config_data_t *)mph->data;
if(keys_per_bin <= 1 || keys_per_bin >= 128)
{
keys_per_bin = 1;
@@ -860,9 +862,10 @@ void chd_ph_load(FILE *fd, cmph_t *mphf)
DEBUGP("Reading n and nbuckets\n");
nbytes = fread(&(chd_ph->n), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fread(&(chd_ph->nbuckets), sizeof(cmph_uint32), (size_t)1, fd);
- if (nbytes == 0 && ferror(fd)) {
+ if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
}
+
}
int chd_ph_dump(cmph_t *mphf, FILE *fd)
@@ -889,7 +892,7 @@ int chd_ph_dump(cmph_t *mphf, FILE *fd)
// dumping n and nbuckets
nbytes = fwrite(&(data->n), sizeof(cmph_uint32), (size_t)1, fd);
nbytes = fwrite(&(data->nbuckets), sizeof(cmph_uint32), (size_t)1, fd);
- if (nbytes == 0 && ferror(fd)) {
+ if (nbytes == 0 && ferror(fd)) {
fprintf(stderr, "ERROR: %s\n", strerror(errno));
return 0;
}