Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/eet
Dir : e17/libs/eet/src/lib
Modified Files:
eet_lib.c
Log Message:
unaligned int access - fix.
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/eet_lib.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -3 -r1.65 -r1.66
--- eet_lib.c 22 Jun 2006 19:22:26 -0000 1.65
+++ eet_lib.c 3 Jul 2006 20:15:54 -0000 1.66
@@ -562,18 +562,22 @@
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);
@@ -621,7 +625,7 @@
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 */
@@ -630,7 +634,7 @@
/* 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 */
@@ -662,14 +666,14 @@
}
/* 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);
@@ -683,7 +687,7 @@
}
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);
@@ -698,7 +702,7 @@
{
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 */
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs