summaryrefslogtreecommitdiff
path: root/src/lib/eet/eet_lib.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2014-01-17 18:55:14 +0900
committerCedric BAIL <cedric.bail@samsung.com>2014-01-20 13:04:06 +0900
commit00d4f5cf1c3e4d950fc7adc12c3e8229b2af99d1 (patch)
tree38790d35cf4d02425ea3dc79e559732c9082b1db /src/lib/eet/eet_lib.c
parentc85414b1572ccd8c37de9020e75f44fd52b15850 (diff)
eet: reduce memory usage of Eet internal structure by removing useless structure.
Diffstat (limited to 'src/lib/eet/eet_lib.c')
-rw-r--r--src/lib/eet/eet_lib.c38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/lib/eet/eet_lib.c b/src/lib/eet/eet_lib.c
index 804ed0eec9..6ff2a3cbd3 100644
--- a/src/lib/eet/eet_lib.c
+++ b/src/lib/eet/eet_lib.c
@@ -387,27 +387,6 @@ eet_flush2(Eet_File *ef)
387 bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE * 387 bytes_dictionary_entries = EET_FILE2_DICTIONARY_ENTRY_SIZE *
388 num_dictionary_entries; 388 num_dictionary_entries;
389 389
390 /* calculate per entry offset */
391 strings_offset = bytes_directory_entries + bytes_dictionary_entries;
392 data_offset = bytes_directory_entries + bytes_dictionary_entries +
393 bytes_strings;
394
395 for (i = 0; i < num; ++i)
396 {
397 for (efn = ef->header->directory->nodes[i]; efn; efn = efn->next)
398 {
399 efn->offset = data_offset;
400 data_offset += efn->size;
401
402 efn->name_offset = strings_offset;
403 strings_offset += efn->name_size;
404 }
405 }
406
407 /* calculate dictionary strings offset */
408 if (ef->ed)
409 ef->ed->offset = strings_offset;
410
411 /* go thru and write the header */ 390 /* go thru and write the header */
412 head[0] = (int)htonl((unsigned int)EET_MAGIC_FILE2); 391 head[0] = (int)htonl((unsigned int)EET_MAGIC_FILE2);
413 head[1] = (int)htonl((unsigned int)num_directory_entries); 392 head[1] = (int)htonl((unsigned int)num_directory_entries);
@@ -417,6 +396,11 @@ eet_flush2(Eet_File *ef)
417 if (fwrite(head, sizeof (head), 1, fp) != 1) 396 if (fwrite(head, sizeof (head), 1, fp) != 1)
418 goto write_error; 397 goto write_error;
419 398
399 /* calculate per entry base offset */
400 strings_offset = bytes_directory_entries + bytes_dictionary_entries;
401 data_offset = bytes_directory_entries + bytes_dictionary_entries +
402 bytes_strings;
403
420 /* write directories entry */ 404 /* write directories entry */
421 for (i = 0; i < num; i++) 405 for (i = 0; i < num; i++)
422 { 406 {
@@ -428,13 +412,18 @@ eet_flush2(Eet_File *ef)
428 flag = (efn->alias << 2) | (efn->ciphered << 1) | efn->compression; 412 flag = (efn->alias << 2) | (efn->ciphered << 1) | efn->compression;
429 flag |= efn->compression_type << 3; 413 flag |= efn->compression_type << 3;
430 414
431 ibuf[0] = (int)htonl((unsigned int)efn->offset); 415 efn->offset = data_offset;
416
417 ibuf[0] = (int)htonl((unsigned int)data_offset);
432 ibuf[1] = (int)htonl((unsigned int)efn->size); 418 ibuf[1] = (int)htonl((unsigned int)efn->size);
433 ibuf[2] = (int)htonl((unsigned int)efn->data_size); 419 ibuf[2] = (int)htonl((unsigned int)efn->data_size);
434 ibuf[3] = (int)htonl((unsigned int)efn->name_offset); 420 ibuf[3] = (int)htonl((unsigned int)strings_offset);
435 ibuf[4] = (int)htonl((unsigned int)efn->name_size); 421 ibuf[4] = (int)htonl((unsigned int)efn->name_size);
436 ibuf[5] = (int)htonl((unsigned int)flag); 422 ibuf[5] = (int)htonl((unsigned int)flag);
437 423
424 strings_offset += efn->name_size;
425 data_offset += efn->size;
426
438 if (fwrite(ibuf, sizeof(ibuf), 1, fp) != 1) 427 if (fwrite(ibuf, sizeof(ibuf), 1, fp) != 1)
439 goto write_error; 428 goto write_error;
440 } 429 }
@@ -445,6 +434,9 @@ eet_flush2(Eet_File *ef)
445 { 434 {
446 int offset = strings_offset; 435 int offset = strings_offset;
447 436
437 /* calculate dictionary strings offset */
438 ef->ed->offset = strings_offset;
439
448 for (j = 0; j < ef->ed->count; ++j) 440 for (j = 0; j < ef->ed->count; ++j)
449 { 441 {
450 int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT]; 442 int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT];