ef->data_size = file_stat.st_size;
ef->data = mmap(NULL, ef->data_size, PROT_READ, MAP_SHARED, fileno(ef->fp), 0);
- if (eet_test_close(ef->data == (void*) -1 || ef->data == NULL, ef))
+ if (eet_test_close((ef->data == (void *)-1) || (ef->data == NULL), ef))
return NULL;
/* build header table if read mode */
/* geat header */
- index += sizeof (int);
- if (eet_test_close((int) ntohl (*((int*) ef->data)) != EET_MAGIC_FILE, ef))
+ index += sizeof(int);
+ if (eet_test_close((int)ntohl(*((int *)ef->data)) != EET_MAGIC_FILE, ef))
return NULL;
-#define EXTRACT_INT(Value, Pointer, Index) \
- Value = ntohl (*((int*)(Pointer + Index))); \
- Index += sizeof(int);
+#define EXTRACT_INT(Value, Pointer, Index) \
+ { \
+ int tmp; \
+ memcpy(&tmp, Pointer + Index, sizeof(int)); \
+ Value = ntohl(tmp); \
+ Index += sizeof(int); \
+ }
/* get entries count and byte count */
EXTRACT_INT(num_entries, ef->data, index);
int hash;
int k;
-#define HEADER_SIZE sizeof (uint32_t) * 5
+#define HEADER_SIZE (sizeof(int) * 5)
/* out directory block is inconsistent - we have oveerun our */
/* dynamic block buffer before we finished scanning dir entries */
/* allocate all the ram needed for this stored node accounting */
efn = malloc (sizeof(Eet_File_Node));
- if (eet_test_close (!efn, ef))
+ if (eet_test_close(!efn, ef))
return NULL;
/* get entrie header */
}
/* This code is useless if we dont want backward compatibility */
- for (k = name_size; k > 0 && ((uint8_t)*(p + HEADER_SIZE + k)) != 0; --k)
+ for (k = name_size; k > 0 && ((uint8_t) * (p + HEADER_SIZE + k)) != 0; --k)
;
- efn->free_name = ((uint8_t)*(p + HEADER_SIZE + k)) != 0;
+ efn->free_name = ((uint8_t) * (p + HEADER_SIZE + k)) != 0;
if (efn->free_name)
{
- efn->name = malloc(sizeof (char) * name_size + 1);
+ efn->name = malloc(sizeof(char) * name_size + 1);
if (eet_test_close(efn->name == NULL, ef))
{
free (efn);
}
else
/* The only really usefull peace of code for efn->name (no backward compatibility) */
- efn->name = (char*) ((uint8_t*)(p + HEADER_SIZE));
+ efn->name = (char*)((uint8_t*)(p + HEADER_SIZE));
/* get hash bucket it should go in */
hash = eet_hash_gen(efn->name, ef->header->directory->size);
{
data = malloc(efn->size);
if (data)
- memcpy (data, ef->data + efn->offset, efn->size);
+ memcpy(data, ef->data + efn->offset, efn->size);
efn->data = data;
}
/* advance */