Commit ccf4af02 authored by Mike Blumenkrantz's avatar Mike Blumenkrantz

unrevert 65828 and unspank myself.


SVN revision: 65832
parent e5cbe139
......@@ -551,3 +551,4 @@
* added eet_file_get to return the filename of an Eet_File
* Eet_File filenames are now stringshared
* added mempool allocators
......@@ -6,6 +6,9 @@ Changes since Eet 1.5.0:
Additions:
* eet_file_get to return filenames of Eet_Files
Improvements:
* most allocations moved to mempools
Eet 1.5.0
......
......@@ -66,6 +66,126 @@ struct _Eet_Node
Eet_Node_Data data;
};
typedef struct _Eet_File_Header Eet_File_Header;
typedef struct _Eet_File_Node Eet_File_Node;
typedef struct _Eet_File_Directory Eet_File_Directory;
struct _Eet_File
{
const char *path;
Eina_File *readfp;
Eet_File_Header *header;
Eet_Dictionary *ed;
Eet_Key *key;
const unsigned char *data;
const void *x509_der;
const void *signature;
void *sha1;
Eet_File_Mode mode;
int magic;
int references;
unsigned long int data_size;
int x509_length;
unsigned int signature_length;
int sha1_length;
Eina_Lock file_lock;
unsigned char writes_pending : 1;
unsigned char delete_me_now : 1;
};
struct _Eet_File_Header
{
int magic;
Eet_File_Directory *directory;
};
struct _Eet_File_Directory
{
int size;
Eet_File_Node **nodes;
};
struct _Eet_File_Node
{
char *name;
void *data;
Eet_File_Node *next; /* FIXME: make buckets linked lists */
unsigned long int offset;
unsigned long int dictionary_offset;
unsigned long int name_offset;
unsigned int name_size;
unsigned int size;
unsigned int data_size;
unsigned char free_name : 1;
unsigned char compression : 1;
unsigned char ciphered : 1;
unsigned char alias : 1;
};
#if 0
/* Version 2 */
/* NB: all int's are stored in network byte order on disk */
/* file format: */
int magic; /* magic number ie 0x1ee7ff00 */
int num_directory_entries; /* number of directory entries to follow */
int bytes_directory_entries; /* bytes of directory entries to follow */
struct
{
int offset; /* bytes offset into file for data chunk */
int flags; /* flags - for now 0 = uncompressed and clear, 1 = compressed and clear, 2 = uncompressed and ciphered, 3 = compressed and ciphered */
int size; /* size of the data chunk */
int data_size; /* size of the (uncompressed) data chunk */
int name_size; /* length in bytes of the name field */
char name[name_size]; /* name string (variable length) and \0 terminated */
} directory[num_directory_entries];
/* and now startes the data stream... */
#endif /* if 0 */
#if 0
/* Version 3 */
/* NB: all int's are stored in network byte order on disk */
/* file format: */
int magic; /* magic number ie 0x1ee70f42 */
int num_directory_entries; /* number of directory entries to follow */
int num_dictionary_entries; /* number of dictionary entries to follow */
struct
{
int data_offset; /* bytes offset into file for data chunk */
int size; /* size of the data chunk */
int data_size; /* size of the (uncompressed) data chunk */
int name_offset; /* bytes offset into file for name string */
int name_size; /* length in bytes of the name field */
int flags; /* bit flags - for now:
bit 0 => compresion on/off
bit 1 => ciphered on/off
bit 2 => alias
*/
} directory[num_directory_entries];
struct
{
int hash;
int offset;
int size;
int prev;
int next;
} dictionary[num_dictionary_entries];
/* now start the string stream. */
/* and right after them the data stream. */
int magic_sign; /* Optional, only if the eet file is signed. */
int signature_length; /* Signature length. */
int x509_length; /* Public certificate that signed the file. */
char signature[signature_length]; /* The signature. */
char x509[x509_length]; /* The public certificate. */
#endif /* if 0 */
/*
* variable and macros used for the eina_log module
*/
......@@ -178,6 +298,21 @@ Eet_Node *
void
eet_node_free(Eet_Node *node);
#define GENERIC_ALLOC_FREE_HEADER(TYPE, Type) \
TYPE *Type##_malloc(unsigned int); \
TYPE *Type##_calloc(unsigned int); \
void Type##_mp_free(TYPE *e);
GENERIC_ALLOC_FREE_HEADER(Eet_File_Directory, eet_file_directory);
GENERIC_ALLOC_FREE_HEADER(Eet_File_Node, eet_file_node);
GENERIC_ALLOC_FREE_HEADER(Eet_File_Header, eet_file_header);
GENERIC_ALLOC_FREE_HEADER(Eet_Dictionary, eet_dictionary);
GENERIC_ALLOC_FREE_HEADER(Eet_File, eet_file);
Eina_Bool eet_mempool_init(void);
void eet_mempool_shutdown(void);
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif /* ifndef PATH_MAX */
......
......@@ -22,6 +22,7 @@ includesdir = $(includedir)/eet-@VMAJ@
lib_LTLIBRARIES = libeet.la
base_sources = \
eet_alloc.c \
eet_lib.c \
eet_data.c \
eet_image.c \
......
......@@ -38,7 +38,6 @@ GENERIC_ALLOC_FREE(Eet_File_Node, eet_file_node);
GENERIC_ALLOC_FREE(Eet_File_Header, eet_file_header);
GENERIC_ALLOC_FREE(Eet_Dictionary, eet_dictionary);
GENERIC_ALLOC_FREE(Eet_File, eet_file);
GENERIC_ALLOC_FREE(Eet_String, eet_string);
static Eet_Mempool *mempool_array[] = {
&eet_file_directory_mp,
......@@ -46,7 +45,6 @@ static Eet_Mempool *mempool_array[] = {
&eet_file_header_mp,
&eet_dictionary_mp,
&eet_file_mp,
&eet_string_mp
};
Eina_Bool
......
......@@ -16,7 +16,7 @@ eet_dictionary_add(void)
{
Eet_Dictionary *new;
new = calloc(1, sizeof (Eet_Dictionary));
new = eet_dictionary_calloc(1);
if (!new)
return NULL;
......@@ -28,21 +28,20 @@ eet_dictionary_add(void)
void
eet_dictionary_free(Eet_Dictionary *ed)
{
if (ed)
{
int i;
int i;
for (i = 0; i < ed->count; ++i)
if (ed->all[i].allocated)
eina_stringshare_del(ed->all[i].str);
if (!ed) return;
if (ed->all)
free(ed->all);
for (i = 0; i < ed->count; ++i)
if (ed->all[i].allocated)
eina_stringshare_del(ed->all[i].str);
if (ed->converts) eina_hash_free(ed->converts);
if (ed->all)
free(ed->all);
free(ed);
}
if (ed->converts) eina_hash_free(ed->converts);
eet_dictionary_mp_free(ed);
}
static int
......@@ -110,7 +109,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
total = ed->total + 8;
new = realloc(ed->all, sizeof (Eet_String) * total);
new = realloc(ed->all, total * sizeof(Eet_String));
if (!new)
return -1;
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment