2008-05-14 Cedric BAIL
- * Fix convertion from a text to a hash (EET_G_HASH).
+ * Fix conversion from a text to a hash (EET_G_HASH).
* Fix inlined string (EET_T_INLINED_STRING) dump/undump by introducing
the new word for the parser 'inlined'.
2009-12-07 Cedric BAIL
* Fix error when retrieving a different float type than the stored one.
- * Reduce convertion with a little memory overhead.
+ * Reduce conversion with a little memory overhead.
2009-12-07 Vincent Torri
* Add a specific allocator for array. This should fix wrong allocation
case discovered with recent edje file format change.
+
+2010-08-23 Carsten Haitzler (The Rasterman)
+
+ * Fix some cppcheck complaints - all of them bogus though.
+ Nothing actually fixed.
+
+2010-08-27 Cedric BAIL
+
+ * Prevent the build of eet data structure that doesn't match what
+ the application is expecting.
+
+2010-09-02 Cedric BAIL
+
+ * Fix bug of ever growing dictionnary and improve strcmp comparison.
-Eet @VERSION@ ALPHA
+Eet @VERSION@ BETA
******************************************************************************
gnutls (1.7.6 or better)
openssl
-Eet is a tiny library designed to write an arbitary set of chunks of
+Eet is a tiny library designed to write an arbitrary set of chunks of
data to a file and optionally compress each chunk (very much like a
zip file) and allow fast random-access reading of the file later
on. It does not do zip as a zip itself has more complexity than is
It also can encode and decode data structures in memory, as well as
image data for saving to eet files or sending across the network to
-other machines, or just writing to arbitary files on the system. All
-data is encoded in a platform independant way and can be written and
+other machines, or just writing to arbitrary files on the system. All
+data is encoded in a platform independent way and can be written and
read by any architecture. This data once encoded can be sent to
another process or machine and decoded on the other end without
needing to go into an eet file. Eet can also optionally encrypt files
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##
-AC_INIT([eet], [v_ver-alpha], [enlightenment-devel@lists.sourceforge.net])
+AC_INIT([eet], [v_ver.beta], [enlightenment-devel@lists.sourceforge.net])
AC_PREREQ([2.52])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
-Revision 51480
-Last Changed Rev 51457
+Revision 53437
+Last Changed Rev 53177
Depends: libeet1 (= ${binary:Version}), libjpeg62-dev, pkg-config
Recommends: libeet-doc
Description: Enlightenment DR17 file chunk reading/writing library development files
- Eet is a tiny library designed to write an arbitary set of chunks of data to a
+ Eet is a tiny library designed to write an arbitrary set of chunks of data to a
file and optionally compress each chunk (very much like a zip file) and allow
fast random-access reading of the file later on. It does not do zip as zip
itself has more complexity than we need, and it was much simpler to implement
Architecture: all
Enhances: libeet-dev
Description: libeet1 API documentation
- Eet is a tiny library designed to write an arbitary set of chunks of data to a
+ Eet is a tiny library designed to write an arbitrary set of chunks of data to a
file and optionally compress each chunk (very much like a zip file) and allow
fast random-access reading of the file later on. It does not do zip as zip
itself has more complexity than we need, and it was much simpler to implement
Architecture: any
Depends: ${shlibs:Depends}
Description: Enlightenment DR17 file chunk reading/writing library
- Eet is a tiny library designed to write an arbitary set of chunks of data to a
+ Eet is a tiny library designed to write an arbitrary set of chunks of data to a
file and optionally compress each chunk (very much like a zip file) and allow
fast random-access reading of the file later on. It does not do zip as zip
itself has more complexity than we need, and it was much simpler to implement
Architecture: any
Depends: ${shlibs:Depends}
Description: Enlightenment DR17 file chunk reading/writing utility
- Eet is a tiny library designed to write an arbitary set of chunks of data to a
+ Eet is a tiny library designed to write an arbitrary set of chunks of data to a
file and optionally compress each chunk (very much like a zip file) and allow
fast random-access reading of the file later on. It does not do zip as zip
itself has more complexity than we need, and it was much simpler to implement
Priority: extra
Depends: libeet1 (= ${binary:Version})
Description: Enlightenment DR17 file chunk reading/writing library - debug symbols
- Eet is a tiny library designed to write an arbitary set of chunks of data to a
+ Eet is a tiny library designed to write an arbitrary set of chunks of data to a
file and optionally compress each chunk (very much like a zip file) and allow
fast random-access reading of the file later on. It does not do zip as zip
itself has more complexity than we need, and it was much simpler to implement
@section intro What is Eet?
-It is a tiny library designed to write an arbitary set of chunks of data
+It is a tiny library designed to write an arbitrary set of chunks of data
to a file and optionally compress each chunk (very much like a zip file)
and allow fast random-access reading of the file later on. It does not
do zip as a zip itself has more complexity than is needed, and it was much
-simpler to impliment this once here.
+simpler to implement this once here.
Eet is extremely fast, small and simple. Eet files can be very small and
highly compressed, making them very optimal for just sending across the
It also can encode and decode data structures in memory, as well as image
data for saving to Eet files or sending across the network to other
-machines, or just writing to arbitary files on the system. All data is
-encoded in a platform independant way and can be written and read by any
+machines, or just writing to arbitrary files on the system. All data is
+encoded in a platform independent way and can be written and read by any
architecture.
@section example A simple example on using Eet
BuildRoot: %{_tmppath}/%{name}-%{version}-root
%description
-Eet is a tiny library designed to write an arbitary set of chunks of
+Eet is a tiny library designed to write an arbitrary set of chunks of
data to a file and optionally compress each chunk (very much like a
zip file) and allow fast random-access reading of the file later
on. It does not do zip as a zip itself has more complexity than is
It also can encode and decode data structures in memory, as well as
image data for saving to eet files or sending across the network to
-other machines, or just writing to arbitary files on the system. All
-data is encoded in a platform independant way and can be written and
+other machines, or just writing to arbitrary files on the system. All
+data is encoded in a platform independent way and can be written and
read by any architecture.
%package devel
dnl Macro that checks if a binary is built or not
dnl Usage: EFL_ENABLE_BIN(binary)
-dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being tranformed into _)
-dnl Define have_binary (- is tranformed into _)
-dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being tranformed into _)
+dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _)
+dnl Define have_binary (- is transformed into _)
+dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _)
AC_DEFUN([EFL_ENABLE_BIN],
[
dnl Macro that specifies the binary to be used
dnl Usage: EFL_WITH_BIN(binary, package, msg)
-dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being tranformed into _)
-dnl Define with_binary (- is tranformed into _)
-dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being tranformed into _)
+dnl Call AC_SUBST(BINARY_PRG) (BINARY is the uppercase of binary, - being transformed into _)
+dnl Define with_binary (- is transformed into _)
+dnl Define conditional BUILD_BINARY (BINARY is the uppercase of binary, - being transformed into _)
AC_DEFUN([EFL_WITH_BIN],
[
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
{
- ERR("cannot open for reading: %s\n", file);
+ ERR("cannot open for reading: %s", file);
exit(-1);
}
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
{
- ERR("cannot open for reading: %s\n", file);
+ ERR("cannot open for reading: %s", file);
exit(-1);
}
data = eet_read_cipher(ef, key, &size, crypto_key);
if (!data)
{
- ERR("cannot read key %s\n", key);
+ ERR("cannot read key %s", key);
exit(-1);
}
f = fopen(out, "wb");
if (!f)
{
- ERR("cannot open %s\n", out);
+ ERR("cannot open %s", out);
exit(-1);
}
if (fwrite(data, size, 1, f) != 1)
{
- ERR("cannot write to %s\n", out);
+ ERR("cannot write to %s", out);
exit(-1);
}
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
{
- ERR("cannot open for reading: %s\n", file);
+ ERR("cannot open for reading: %s", file);
exit(-1);
}
f = fopen(out, "wb");
if (!f)
{
- ERR("cannot open %s\n", out);
+ ERR("cannot open %s", out);
exit(-1);
}
if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f))
{
- ERR("cannot write to %s\n", out);
+ ERR("cannot write to %s", out);
exit(-1);
}
if (!ef)
{
- ERR("cannot open for read+write: %s\n", file);
+ ERR("cannot open for read+write: %s", file);
exit(-1);
}
f = fopen(out, "rb");
if (!f)
{
- ERR("cannot open %s\n", out);
+ ERR("cannot open %s", out);
exit(-1);
}
data = malloc(size);
if (!data)
{
- ERR("cannot allocate %i bytes\n", size);
+ ERR("cannot allocate %i bytes", size);
exit(-1);
}
if (fread(data, size, 1, f) != 1)
{
- ERR("cannot read file %s\n", out);
+ ERR("cannot read file %s", out);
exit(-1);
}
if (!ef)
{
- ERR("cannot open for read+write: %s\n", file);
+ ERR("cannot open for read+write: %s", file);
exit(-1);
}
f = fopen(out, "rb");
if (!f)
{
- ERR("cannot open %s\n", out);
+ ERR("cannot open %s", out);
exit(-1);
}
text = malloc(textlen);
if (!text)
{
- ERR("cannot allocate %i bytes\n", size);
+ ERR("cannot allocate %i bytes", size);
exit(-1);
}
if (fread(text, textlen, 1, f) != 1)
{
- ERR("cannot read file %s\n", out);
+ ERR("cannot read file %s", out);
exit(-1);
}
fclose(f);
if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress))
{
- ERR("cannot parse %s\n", out);
+ ERR("cannot parse %s", out);
exit(-1);
}
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef)
{
- ERR("cannot open for read+write: %s\n", file);
+ ERR("cannot open for read+write: %s", file);
exit(-1);
}
ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef)
{
- ERR("checking signature of `%s` failed\n", file);
+ ERR("checking signature of `%s` failed", file);
exit(-1);
}
ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef)
{
- ERR("cannot open for read+write: %s.\n", file);
+ ERR("cannot open for read+write: %s.", file);
exit(-1);
}
key = eet_identity_open(public_key, private_key, NULL);
if (!key)
{
- ERR("cannot open key '%s:%s'.\n", public_key, private_key);
+ ERR("cannot open key '%s:%s'.", public_key, private_key);
exit(-1);
}
if (!eet_init())
return -1;
- _eet_main_log_dom = eina_log_domain_register("Eet_Main",EINA_COLOR_CYAN);
+ _eet_main_log_dom = eina_log_domain_register("eet_main", EINA_COLOR_CYAN);
if(_eet_main_log_dom < -1)
{
- EINA_LOG_ERR("Impossible to create a log domain for eet_main.\n");
+ EINA_LOG_ERR("Impossible to create a log domain for eet_main.");
eet_shutdown();
return(-1);
}
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag.
- * @return 1 on successfull decode, 0 otherwise
+ * @return 1 on successful decode, 0 otherwise
*
* This function reads an image from an eet file stored under the named
* key in the eet file and return a pointer to the decompressed pixel data.
* @param compress A pointer to the int to hold the compression amount.
* @param quality A pointer to the int to hold the quality amount.
* @param lossy A pointer to the int to hold the lossiness flag.
- * @return 1 on successfull decode, 0 otherwise
+ * @return 1 on successful decode, 0 otherwise
*
* This function reads an image from an eet file stored under the named
* key in the eet file and return a pointer to the decompressed pixel data.
char *(*str_direct_alloc)(const char *str); /**< how to allocate a string directly from file backed/mmaped region pointed by @p str */
void (*str_direct_free)(const char *str); /**< how to free a string returned by str_direct_alloc */
const char *(*type_get)(const void *data, Eina_Bool *unknow); /**< convert any kind of data type to a name that define an Eet_Data_Element. */
- Eina_Bool (*type_set)(const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular adress */
+ Eina_Bool (*type_set)(const char *type, void *data, Eina_Bool unknow); /**< set the type at a particular address */
void *(*array_alloc)(size_t size); /**< how to allocate memory for array (usually malloc()) */
void (*array_free)(void *mem); /**< how to free memory for array (usually free()) */
} func;
*
* Once you have described all the members of a struct you want loaded, or
* saved eet can load and save those members for you, encode them into
- * endian-independant serialised data chunks for transmission across a
+ * endian-independent serialised data chunks for transmission across a
* a network or more.
*
* The function pointers to the list and hash table functions are only
*
* Once you have described all the members of a struct you want loaded, or
* saved eet can load and save those members for you, encode them into
- * endian-independant serialised data chunks for transmission across a
+ * endian-independent serialised data chunks for transmission across a
* a network or more.
*
* This function specially ignore str_direct_alloc and str_direct_free. It
- * is usefull when the eet_data you are reading don't have a dictionnary
+ * is useful when the eet_data you are reading don't have a dictionnary
* like network stream or ipc. It also mean that all string will be allocated
* and duplicated in memory.
*
*
* Once you have described all the members of a struct you want loaded, or
* saved eet can load and save those members for you, encode them into
- * endian-independant serialised data chunks for transmission across a
+ * endian-independent serialised data chunks for transmission across a
* a network or more.
*
* This function use str_direct_alloc and str_direct_free. It is
- * usefull when the eet_data you are reading come from a file and
+ * useful when the eet_data you are reading come from a file and
* have a dictionnary. This will reduce memory use, improve the
* possibility for the OS to page this string out. But be carrefull
* all EET_T_STRING are pointer to a mmapped area and it will point
* with a stream.
* @param eddc The Eet_Data_Descriptor_Class you want to set.
* @param name The name of the structure described by this class.
+ * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compilation time.
* @param size The size of the structure described by this class.
* @return EINA_TRUE if the structure was correctly set (The only
* reason that could make it fail is if you did give wrong
* This macro is an helper that set all the parameter of an
* Eet_Data_Descriptor_Class correctly when you use Eina data type
* with stream.
- * @param Clas The Eet_Data_Descriptor_Class you want to set.
- * @param Type The type of the structure described by this class.
+ * @param clas The Eet_Data_Descriptor_Class you want to set.
+ * @param type The type of the structure described by this class.
* @return EINA_TRUE if the structure was correctly set (The only
* reason that could make it fail is if you did give wrong
* parameter).
* Eet_Data_Descriptor_Class correctly when you use Eina data type
* with a file.
* @param eddc The Eet_Data_Descriptor_Class you want to set.
+ * @param eddc_size The size of the Eet_Data_Descriptor_Class at the compilation time.
* @param name The name of the structure described by this class.
* @param size The size of the structure described by this class.
* @return EINA_TRUE if the structure was correctly set (The only
* This macro is an helper that set all the parameter of an
* Eet_Data_Descriptor_Class correctly when you use Eina data type
* with file.
- * @param Clas The Eet_Data_Descriptor_Class you want to set.
- * @param Type The type of the structure described by this class.
+ * @param clas The Eet_Data_Descriptor_Class you want to set.
+ * @param type The type of the structure described by this class.
* @return EINA_TRUE if the structure was correctly set (The only
* reason that could make it fail is if you did give wrong
* parameter).
int compress);
/**
- * Decode a data structure from an arbitary location in memory.
+ * Decode a data structure from an arbitrary location in memory.
* @param edd The data descriptor to use when decoding.
* @param data_in The pointer to the data to decode into a struct.
* @param size_in The size of the data pointed to in bytes.
int compress);
/**
- * Decode a data structure from an arbitary location in memory
+ * Decode a data structure from an arbitrary location in memory
* using a cipher.
* @param edd The data descriptor to use when decoding.
* @param data_in The pointer to the data to decode into a struct.
/**
* Instanciate a new connection to track.
- * @oaram eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
+ * @param eet_read_cb Function to call when one Eet_Data packet has been fully assemble.
* @param eet_write_cb Function to call when one Eet_Data packet is ready to be send over the wire.
* @param user_data Pointer provided to both functions to be used as a context handler.
* @return NULL on failure, or a valid Eet_Connection handler.
/**
* Process a raw packet received over the link
- * @oaram conn Connection handler to track.
+ * @param conn Connection handler to track.
* @param data Raw data packet.
* @param size The size of that packet.
* @return 0 on complete success, any other value indicate where in the stream it got wrong (It could be before that packet).
/**
* Convert a complex structure and prepare it to be send.
- * @oaram conn Connection handler to track.
+ * @param conn Connection handler to track.
* @param edd The data descriptor to use when encoding.
* @param data_in The pointer to the struct to encode into data.
* @param cipher_key The key to use as cipher.
/**
* Convert a Eet_Node tree and prepare it to be send.
- * @oaram conn Connection handler to track.
+ * @param conn Connection handler to track.
* @param node The data tree to use when encoding.
* @param cipher_key The key to use as cipher.
* @return EINA_TRUE if the data where correctly send, EINA_FALSE if they don't.
/**
* Close a connection and lost its track.
- * @oaram conn Connection handler to close.
+ * @param conn Connection handler to close.
* @param on_going Signal if a partial packet wasn't completed.
* @return the user_data passed to both callback.
*
EVP_PKEY_free(pkey);
# endif /* ifdef HAVE_GNUTLS */
+#else
+ certificate_file = NULL;
+ private_key_file = NULL;
+ cb = NULL;
#endif /* ifdef HAVE_SIGNATURE */
return NULL;
} /* eet_identity_open */
EVP_PKEY_free(key->private_key);
# endif /* ifdef HAVE_GNUTLS */
free(key);
+#else
+ key = NULL;
#endif /* ifdef HAVE_SIGNATURE */
} /* eet_identity_close */
X509_print_fp(out, key->certificate);
# endif /* ifdef HAVE_GNUTLS */
#else /* ifdef HAVE_SIGNATURE */
+ key = NULL;
+ out = NULL;
ERR("You need to compile signature support in EET.");
#endif /* ifdef HAVE_SIGNATURE */
} /* eet_identity_print */
void
eet_identity_ref(Eet_Key *key)
{
- if (key == NULL)
+ if (!key)
return;
key->references++;
void
eet_identity_unref(Eet_Key *key)
{
- if (key == NULL)
+ if (!key)
return;
key->references--;
# endif /* ifdef HAVE_OPENSSL */
# endif /* ifdef HAVE_GNUTLS */
#else /* ifdef HAVE_SIGNATURE */
+ data_base = NULL;
+ data_length = 0;
+ sha1_length = NULL;
result = NULL;
#endif /* ifdef HAVE_SIGNATURE */
# else /* ifdef HAVE_GNUTLS */
sign_len = EVP_PKEY_size(key->private_key);
sign = malloc(sign_len);
- if (sign == NULL)
+ if (!sign)
{
err = EET_ERROR_OUT_OF_MEMORY;
goto on_error;
munmap(data, st_buf.st_size);
return err;
#else /* ifdef HAVE_SIGNATURE */
+ fp = NULL;
+ key = NULL;
return EET_ERROR_NOT_IMPLEMENTED;
#endif /* ifdef HAVE_SIGNATURE */
} /* eet_identity_sign */
gcry_md_write(md, data_base, data_length);
hash = gcry_md_read(md, GCRY_MD_SHA1);
- if (hash == NULL)
+ if (!hash)
{
gcry_md_close(md);
return NULL;
tmp = alloca(cert_len);
memcpy((char *)tmp, cert_der, cert_len);
x509 = d2i_X509(NULL, &tmp, cert_len);
- if (x509 == NULL)
+ if (!x509)
return NULL;
/* Get public key - eay */
pkey = X509_get_pubkey(x509);
- if (pkey == NULL)
+ if (!pkey)
{
X509_free(x509);
return NULL;
return cert_der;
#else /* ifdef HAVE_SIGNATURE */
+ data_base = NULL;
+ data_length = 0;
+ sha1 = NULL;
+ sha1_length = NULL;
+ signature_base = NULL;
+ signature_length = 0;
+ raw_signature_base = NULL;
+ raw_signature_length = NULL;
+ x509_length = NULL;
return NULL;
#endif /* ifdef HAVE_SIGNATURE */
} /* eet_identity_check */
tmp = alloca(der_length);
memcpy((char *)tmp, certificate, der_length);
x509 = d2i_X509(NULL, &tmp, der_length);
- if (x509 == NULL)
+ if (!x509)
{
INF("Not a valid certificate.");
return;
X509_free(x509);
# endif /* ifdef HAVE_GNUTLS */
#else /* ifdef HAVE_SIGNATURE */
+ certificate = NULL;
+ der_length = 0;
+ out = NULL;
ERR("You need to compile signature support in EET.");
#endif /* ifdef HAVE_SIGNATURE */
} /* eet_identity_certificate_print */
gcry_md_write(mdh, data, data_len);
hash = gcry_md_read(mdh, GCRY_MD_SHA1);
- if (hash == NULL)
+ if (!hash)
{
gcry_md_close(mdh);
return 1;
return -1;
str = eet_dictionary_string_get_char(ed, idx);
- if (str == NULL)
+ if (!str)
return -1;
*d = (char *)str;
}
s = (char *)src;
- if (s == NULL)
+ if (!s)
{
*d = NULL;
return 0;
|| group_type == EET_G_VARIANT)
&&
(type != EET_T_UNKNOW
- || subtype == NULL
- || subtype->func.type_get == NULL
- || subtype->func.type_set == NULL))
+ || !subtype
+ || !subtype->func.type_get
+ || !subtype->func.type_set))
return;
/* VARIANT type will only work if the map only contains EET_G_*, but not UNION, VARIANT and ARRAY. */
&& (group_type < EET_G_LAST)
&& (((type > EET_T_UNKNOW) && (type < EET_T_STRING))
|| ((type > EET_T_NULL) && (type < EET_T_LAST)))
- && (subtype == NULL))
+ && (!subtype))
{
subtype = calloc(1, sizeof (Eet_Data_Descriptor));
if (!subtype)
} /* _eet_free_add */
static void
+_eet_free_del(Eet_Free *ef,
+ void *data)
+{
+ int hash;
+ int i;
+
+ hash = _eet_free_hash(data);
+
+ for (i = 0; i < ef->num[hash]; ++i)
+ if (ef->list[hash][i] == data)
+ {
+ ef->list[hash][i] = NULL;
+ return;
+ }
+}
+
+static void
_eet_free_reset(Eet_Free *ef)
{
int i;
} /* _eet_free_unref */
#define _eet_freelist_add(Ctx, Data) _eet_free_add(&Ctx->freelist, Data);
+#define _eet_freelist_del(Ctx, Data) _eet_free_del(&Ctx->freelist, Data);
#define _eet_freelist_reset(Ctx) _eet_free_reset(&Ctx->freelist);
#define _eet_freelist_ref(Ctx) _eet_free_ref(&Ctx->freelist);
#define _eet_freelist_unref(Ctx) _eet_free_unref(&Ctx->freelist);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist.num[j]; ++i)
- {
- if (edd)
- edd->func.mem_free(context->freelist.list[j][i]);
- else
- free(context->freelist.list[j][i]);
- }
+ if (context->freelist.list[j][i])
+ {
+ if (edd)
+ edd->func.mem_free(context->freelist.list[j][i]);
+ else
+ free(context->freelist.list[j][i]);
+ }
_eet_free_reset(&context->freelist);
} /* _eet_freelist_free */
#define _eet_freelist_array_add(Ctx, Data) _eet_free_add(&Ctx->freelist_array, Data);
+#define _eet_freelist_array_del(Ctx, Data) _eet_free_del(&Ctx->freelist_array, Data);
#define _eet_freelist_array_reset(Ctx) _eet_free_reset(&Ctx->freelist_array);
#define _eet_freelist_array_ref(Ctx) _eet_free_ref(&Ctx->freelist_array);
#define _eet_freelist_array_unref(Ctx) _eet_free_unref(&Ctx->freelist_array);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist_array.num[j]; ++i)
- {
- if (edd)
- {
- if (edd->func.array_free)
- edd->func.array_free(context->freelist_array.list[j][i]);
- else
- edd->func.mem_free(context->freelist_array.list[j][i]);
- }
- else
- free(context->freelist_array.list[j][i]);
- }
+ if (context->freelist_array.list[j][i])
+ {
+ if (edd)
+ {
+ if (edd->func.array_free)
+ edd->func.array_free(context->freelist_array.list[j][i]);
+ else
+ edd->func.mem_free(context->freelist_array.list[j][i]);
+ }
+ else
+ free(context->freelist_array.list[j][i]);
+ }
_eet_free_reset(&context->freelist_array);
} /* _eet_freelist_array_free */
#define _eet_freelist_list_add(Ctx, Data) _eet_free_add(&Ctx->freelist_list, Data);
+#define _eet_freelist_list_del(Ctx, Data) _eet_free_del(&Ctx->freelist_list, Data);
#define _eet_freelist_list_reset(Ctx) _eet_free_reset(&Ctx->freelist_list);
#define _eet_freelist_list_ref(Ctx) _eet_free_ref(&Ctx->freelist_list);
#define _eet_freelist_list_unref(Ctx) _eet_free_unref(&Ctx->freelist_list);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist_list.num[j]; ++i)
- {
- if (edd)
- edd->func.list_free(*((void **)(context->freelist_list.list[j][i])));
- }
+ if (context->freelist_list.list[j][i])
+ {
+ if (edd)
+ edd->func.list_free(*((void **)(context->freelist_list.list[j][i])));
+ }
_eet_free_reset(&context->freelist_list);
} /* _eet_freelist_list_free */
#define _eet_freelist_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_str, Data);
+#define _eet_freelist_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_str, Data);
#define _eet_freelist_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_str);
#define _eet_freelist_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_str);
#define _eet_freelist_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_str);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist_str.num[j]; ++i)
- {
- if (edd)
- edd->func.str_free(context->freelist_str.list[j][i]);
- else
- free(context->freelist_str.list[j][i]);
- }
+ if (context->freelist_str.list[j][i])
+ {
+ if (edd)
+ edd->func.str_free(context->freelist_str.list[j][i]);
+ else
+ free(context->freelist_str.list[j][i]);
+ }
_eet_free_reset(&context->freelist_str);
} /* _eet_freelist_str_free */
#define _eet_freelist_direct_str_add(Ctx, Data) _eet_free_add(&Ctx->freelist_direct_str, Data);
+#define _eet_freelist_direct_str_del(Ctx, Data) _eet_free_del(&Ctx->freelist_direct_str, Data);
#define _eet_freelist_direct_str_reset(Ctx) _eet_free_reset(&Ctx->freelist_direct_str);
#define _eet_freelist_direct_str_ref(Ctx) _eet_free_ref(&Ctx->freelist_direct_str);
#define _eet_freelist_direct_str_unref(Ctx) _eet_free_unref(&Ctx->freelist_direct_str);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist_direct_str.num[j]; ++i)
- {
- if (edd)
- edd->func.str_direct_free(context->freelist_direct_str.list[j][i]);
- else
- free(context->freelist_direct_str.list[j][i]);
- }
+ if (context->freelist_direct_str.list[j][i])
+ {
+ if (edd)
+ edd->func.str_direct_free(context->freelist_direct_str.list[j][i]);
+ else
+ free(context->freelist_direct_str.list[j][i]);
+ }
_eet_free_reset(&context->freelist_direct_str);
} /* _eet_freelist_direct_str_free */
#define _eet_freelist_hash_add(Ctx, Data) _eet_free_add(&Ctx->freelist_hash, Data);
+#define _eet_freelist_hash_del(Ctx, Data) _eet_free_del(&Ctx->freelist_hash, Data);
#define _eet_freelist_hash_reset(Ctx) _eet_free_reset(&Ctx->freelist_hash);
#define _eet_freelist_hash_ref(Ctx) _eet_free_ref(&Ctx->freelist_hash);
#define _eet_freelist_hash_unref(Ctx) _eet_free_unref(&Ctx->freelist_hash);
for (j = 0; j < 256; ++j)
for (i = 0; i < context->freelist_hash.num[j]; ++i)
- {
- if (edd)
- edd->func.hash_free(context->freelist_hash.list[j][i]);
- else
- free(context->freelist_hash.list[j][i]);
- }
+ if (context->freelist_hash.list[j][i])
+ {
+ if (edd)
+ edd->func.hash_free(context->freelist_hash.list[j][i]);
+ else
+ free(context->freelist_hash.list[j][i]);
+ }
_eet_free_reset(&context->freelist_hash);
} /* _eet_freelist_hash_free */
_eet_data_words_bigendian = 0;
}
- if (node == NULL)
+ if (!node)
return NULL;
ds = eet_data_stream_new();
&echnk,
type,
group_type,
- ede ? (void *)(((char
- *)
- data)
- + ede->
- offset)
- : (void **)&result,
+ ede ? (void *)(((char*) data) + ede->offset) : (void **)&result,
&p,
&size);
if (ret <= 0)
- goto error;
+ goto error;
}
/* advance to next chunk */
EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
- if (edd)
+ if (ede)
{
subtype = ede->subtype;
if (ret <= 0)
goto on_error;
+ if (!key)
+ goto on_error;
+
/* Advance to next chunk */
NEXT_CHUNK((*p), (*size), (*echnk), ed);
memset(echnk, 0, sizeof(Eet_Data_Chunk));
if (!echnk->name)
goto on_error;
+ if (ede)
+ if ((ede->group_type != echnk->group_type)
+ || (ede->type != echnk->type))
+ goto on_error;
+
if (IS_POINTER_TYPE(echnk->type))
POINTER_TYPE_DECODE(context,
ed,
return 1;
on_error:
- return ret;
+ return 0;
} /* eet_data_get_hash */
/* var arrays and fixed arrays have to
memcpy(dst, data_ret, subsize);
if (edd) edd->func.mem_free(data_ret);
else free(data_ret);
+ _eet_freelist_del(context, data_ret);
}
if (!edd)
sede->group_type, data, &p2, &size2);
if (ret <= 0)
- goto on_error;
+ goto on_error;
/* advance to next chunk */
NEXT_CHUNK(p2, size2, chnk, ed);
str = (char **)(((char *)data));
if (*str)
{
- if ((ed == NULL) || (edd->func.str_direct_alloc == NULL))
+ if ((!ed) || (!edd->func.str_direct_alloc))
{
*str = edd->func.str_alloc(*str);
_eet_freelist_str_add(context, *str);
static int
_eet_dictionary_lookup(Eet_Dictionary *ed,
const char *string,
+ int len,
int hash)
{
+ Eina_Bool found = EINA_FALSE;
int prev = -1;
int current;
while (current != -1)
{
- if (ed->all[current].str)
- if (strcmp(ed->all[current].str, string) >= 0)
- break;
-
- if (ed->all[current].mmap)
- if (strcmp(ed->all[current].mmap, string) >= 0)
- break;
+ if (ed->all[current].len == len)
+ {
+ if (ed->all[current].str)
+ if (strcmp(ed->all[current].str, string) == 0)
+ {
+ found = EINA_TRUE;
+ break;
+ }
+
+ if (ed->all[current].mmap)
+ if (strcmp(ed->all[current].mmap, string) == 0)
+ {
+ found = EINA_TRUE;
+ break;
+ }
+ }
prev = current;
current = ed->all[current].next;
}
- if (current == -1)
+ if (current == -1 && found)
return prev;
return current;
return -1;
hash = _eet_hash_gen(string, 8);
+ len = strlen(string) + 1;
- idx = _eet_dictionary_lookup(ed, string, hash);
+ idx = _eet_dictionary_lookup(ed, string, len, hash);
if (idx != -1)
{
if (ed->all[idx].str)
- if (strcmp(ed->all[idx].str, string) == 0)
- return idx;
+ if (strcmp(ed->all[idx].str, string) == 0)
+ return idx;
if (ed->all[idx].mmap)
- if (strcmp(ed->all[idx].mmap, string) == 0)
- return idx;
-
+ if (strcmp(ed->all[idx].mmap, string) == 0)
+ return idx;
}
if (ed->total == ed->count)
total = ed->total + 8;
new = realloc(ed->all, sizeof (Eet_String) * total);
- if (new == NULL)
+ if (!new)
return -1;
ed->all = new;
ed->total = total;
}
- len = strlen(string) + 1;
str = strdup(string);
- if (str == NULL)
+ if (!str)
return -1;
current = ed->all + ed->count;
{
#ifdef _WIN32
/* Windows file system could change the mmaped file when replacing a file. So we need to copy all string in memory to avoid bugs. */
- if (ed->all[idx].str == NULL)
+ if (!ed->all[idx].str)
{
ed->all[idx].str = strdup(ed->all[idx].mmap);
ed->all[idx].mmap = NULL;
{
int i;
- if ((ed == NULL) || (string == NULL))
+ if ((!ed) || (!string))
return 0;
if ((ed->start <= string) && (string < ed->end))
{
struct jpeg_source_mgr pub;
- const unsigned char *buf;
- size_t len;
+ const unsigned char *buf;
+ size_t len;
+ struct jpeg_membuf_src *self;
};
static void
static void
_eet_jpeg_membuf_src_term(j_decompress_ptr cinfo)
{
- free(cinfo->src);
+ struct jpeg_membuf_src *src = ((struct jpeg_membuf_src *)cinfo->src)->self;
+
+ free(src);
cinfo->src = NULL;
} /* _eet_jpeg_membuf_src_term */
{
struct jpeg_membuf_src *src;
- src = malloc(sizeof(*src));
+ src = calloc(1, sizeof(*src));
if (!src)
return -1;
+ src->self = src;
+
cinfo->src = &src->pub;
src->buf = buf;
src->len = len;
unsigned char *buf;
size_t len;
int failed;
+ struct jpeg_membuf_dst *self;
};
static void
unsigned char *buf;
if (dst->len >= 0x40000000 ||
- (buf = realloc(dst->buf, dst->len * 2)) == NULL)
+ !(buf = realloc(dst->buf, dst->len * 2)))
{
dst->failed = 1;
dst->pub.next_output_byte = dst->buf;
static void
_eet_jpeg_membuf_dst_term(j_compress_ptr cinfo)
{
- struct jpeg_membuf_dst *dst = (struct jpeg_membuf_dst *)cinfo->dest;
+ struct jpeg_membuf_dst *dst = ((struct jpeg_membuf_dst *)cinfo->dest)->self;
if (dst->failed)
{
{
struct jpeg_membuf_dst *dst;
- dst = malloc(sizeof(*dst));
+ dst = calloc(1, sizeof(*dst));
if (!dst)
return -1;
return -1;
}
+ dst->self = dst;
dst->len = 32768;
cinfo->dest = &dst->pub;
/* eet_data_image_lossless_compressed_convert will refuse to compress something
if the result is bigger than the entry. */
- if (comp <= 0 || d == NULL)
+ if (comp <= 0 || !d)
d = eet_data_image_lossless_convert(&size, data, w, h, alpha);
}
else
Bytef *dtmp;
uLongf dlen = src_w * src_h * 4;
- /* FIXME: This could create a huge alloc. So compressed data and tile could not always work. */
+ /* FIXME: This could create a huge alloc. So compressed
+ data and tile could not always work. */
dtmp = malloc(dlen);
if (!dtmp)
return 0;
return --eet_init_count;
}
- _eet_log_dom_global = eina_log_domain_register("Eet", EET_DEFAULT_LOG_COLOR);
+ _eet_log_dom_global = eina_log_domain_register("eet", EET_DEFAULT_LOG_COLOR);
if (_eet_log_dom_global < 0)
{
EINA_LOG_ERR("Eet Can not create a general log domain.");
"BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !");
}
-#ifdef EFL_HAVE_POSIX_THREADS
+# ifdef EFL_HAVE_POSIX_THREADS
if (gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread))
WRN(
"YOU ARE USING PTHREADS, BUT I CANNOT INITIALIZE THREADSAFE GCRYPT OPERATIONS!");
-#endif /* ifdef EFL_HAVE_POSIX_THREADS */
+# endif /* ifdef EFL_HAVE_POSIX_THREADS */
if (gnutls_global_init())
goto shutdown_eet;
return eet_init_count;
+#ifdef HAVE_GNUTLS
shutdown_eet:
+#endif
eet_node_shutdown();
unregister_log_domain:
eina_log_domain_unregister(_eet_log_dom_global);
bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE *
num_dictionary_entries;
- /* we cant have <= 0 values here - invalid */
+ /* we can't have <= 0 values here - invalid */
if (eet_test_close((num_directory_entries <= 0), ef))
return NULL;
- /* we cant have more bytes directory and bytes in dictionaries than the size of the file */
+ /* we can't have more bytes directory and bytes in dictionaries than the size of the file */
if (eet_test_close((bytes_directory_entries + bytes_dictionary_entries) >
ef->data_size, ef))
return NULL;
/* out directory block is inconsistent - we have oveerun our */
/* dynamic block buffer before we finished scanning dir entries */
- efn = malloc (sizeof(Eet_File_Node));
+ efn = malloc(sizeof(Eet_File_Node));
if (eet_test_close(!efn, ef))
- return NULL;
+ {
+ if (efn) free(efn); /* yes i know - we only get here if
+ * efn is null/0 -> trying to shut up
+ * warning tools like cppcheck */
+ return NULL;
+ }
/* get entrie header */
GET_INT(efn->offset, data, idx);
&ef->signature_length,
&ef->x509_length);
- if (eet_test_close(ef->x509_der == NULL, ef))
+ if (eet_test_close(!ef->x509_der, ef))
return NULL;
#else /* ifdef HAVE_SIGNATURE */
EXTRACT_INT(num_entries, ef->data, idx);
EXTRACT_INT(byte_entries, ef->data, idx);
- /* we cant have <= 0 values here - invalid */
+ /* we can't have <= 0 values here - invalid */
if (eet_test_close((num_entries <= 0) || (byte_entries <= 0), ef))
return NULL;
/* allocate all the ram needed for this stored node accounting */
efn = malloc (sizeof(Eet_File_Node));
if (eet_test_close(!efn, ef))
- return NULL;
+ {
+ if (efn) free(efn); /* yes i know - we only get here if
+ * efn is null/0 -> trying to shut up
+ * warning tools like cppcheck */
+ return NULL;
+ }
/* get entrie header */
EXTRACT_INT(efn->offset, p, indexn);
if (efn->free_name)
{
efn->name = malloc(sizeof(char) * name_size + 1);
- if (eet_test_close(efn->name == NULL, ef))
+ if (eet_test_close(!efn->name, ef))
{
free(efn);
return NULL;
efn->name);
}
else
- /* The only really usefull peace of code for efn->name (no backward compatibility) */
+ /* The only really useful peace of code for efn->name (no backward compatibility) */
efn->name = (char *)((unsigned char *)(p + HEADER_SIZE));
/* get hash bucket it should go in */
{
const int *data = (const int *)ef->data;
- if (eet_test_close((ef->data == (void *)-1) || (ef->data == NULL), ef))
+ if (eet_test_close((ef->data == (void *)-1) || (!ef->data), ef))
return NULL;
if (eet_test_close(ef->data_size < (int)sizeof(int) * 3, ef))
{
Eet_File *ef;
- if (data == NULL || size == 0)
+ if (!data || size == 0)
return NULL;
ef = malloc (sizeof (Eet_File));
}
open_error:
- if (fp == NULL && mode == EET_FILE_MODE_READ)
+ if (!fp && mode == EET_FILE_MODE_READ)
goto on_error;
}
else
if (ef)
{
/* reference it up and return it */
- if (fp != NULL)
+ if (fp)
fclose(fp);
ef->references++;
ef->sha1_length = 0;
ef->ed = (mode == EET_FILE_MODE_WRITE)
- || (ef->readfp == NULL && mode == EET_FILE_MODE_READ_WRITE) ?
+ || (!ef->readfp && mode == EET_FILE_MODE_READ_WRITE) ?
eet_dictionary_add() : NULL;
- if (ef->readfp == NULL &&
+ if (!ef->readfp &&
(mode == EET_FILE_MODE_READ_WRITE || mode == EET_FILE_MODE_WRITE))
goto empty_file;
{
void *data_deciphered = NULL;
unsigned int data_deciphered_sz = 0;
- /* if we alreayd have the data in ram... copy that */
+ /* if we already have the data in ram... copy that */
if (efn->data)
memcpy(data, efn->data, efn->size);
if (!efn)
goto on_error;
- if (efn->offset < 0 && efn->data == NULL)
+ if (efn->offset < 0 && !efn->data)
goto on_error;
/* get size (uncompressed, if compressed at all) */
unsigned int data_ciphered_sz = 0;
const void *tmp;
- tmp = data2 ? data2 : data;
+ tmp = comp ? data2 : data;
if (!eet_cipher(tmp, data_size, cipher_key, strlen(cipher_key),
&data_ciphered, &data_ciphered_sz))
{
}
}
else
- if (!comp)
- memcpy(data2, data, size);
+ if (!comp)
+ memcpy(data2, data, size);
/* Does this node already exist? */
for (efn = ef->header->directory->nodes[hash]; efn; efn = efn->next)
if (efn->data)
free(efn->data);
- if (pefn == NULL)
+ if (!pefn)
ef->header->directory->nodes[hash] = efn->next;
else
pefn->next = efn->next;
dumpfunc(dumpdata, "\";\n");
}
- for (it = n->values; it != NULL; it = it->next)
+ for (it = n->values; it; it = it->next)
eet_node_dump(it, dumplevel + 2, dumpfunc, dumpdata);
eet_node_dump_group_end(dumplevel, dumpfunc, dumpdata);
case EET_G_UNKNOWN:
me = cb->struct_alloc(root->name, user_data);
- for (it = root->values; it != NULL; it = it->next)
+ for (it = root->values; it; it = it->next)
eet_node_walk(me, it->name, it, cb, user_data);
break;
me = cb->array(root->type == EET_G_VAR_ARRAY ? EINA_TRUE : EINA_FALSE,
root->name, root->count, user_data);
- for (i = 0, it = root->values; it != NULL; it = it->next)
+ for (i = 0, it = root->values; it; it = it->next)
cb->insert(me, i++, eet_node_walk(NULL,
NULL,
it,
case EET_G_LIST:
me = cb->list(root->name, user_data);
- for (it = root->values; it != NULL; it = it->next)
+ for (it = root->values; it; it = it->next)
cb->append(me, eet_node_walk(NULL,
NULL,
it,
s = eet_suite();
sr = srunner_create(s);
- srunner_run_all(sr, CK_NORMAL);
+ srunner_run_all(sr, CK_ENV);
failed_count = srunner_ntests_failed(sr);
srunner_free(sr);