summaryrefslogtreecommitdiff
path: root/src/bin/tyls.c
diff options
context:
space:
mode:
authorThibaut Broggi <broggi_t@epitech.eu>2015-02-26 23:09:54 +0100
committerBoris Faure <billiob@gmail.com>2015-02-26 23:47:28 +0100
commit85edd0407c0359871ee6bb855fc206a9c3f4ad74 (patch)
tree8932608d2aae53acc59c670655729282cb5c575d /src/bin/tyls.c
parent03b88bafc755e93c75c17a10902b8b3e070eeb56 (diff)
tyls: remove leaks and fix write() checking
leaks were due to a "return 0" in main() removing it, so that the exit functions from ecore can run properly changing the way write() was checked, now we check if all chars are printed
Diffstat (limited to 'src/bin/tyls.c')
-rw-r--r--src/bin/tyls.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/bin/tyls.c b/src/bin/tyls.c
index d145fd9..048ca7d 100644
--- a/src/bin/tyls.c
+++ b/src/bin/tyls.c
@@ -51,9 +51,9 @@ size_print(char *buf, int bufsz, char *sz, unsigned long long size)
51 51
52 while (prefixes[i]) 52 while (prefixes[i])
53 { 53 {
54 if (size < (unsigned long long)pow(1024LL, i + 1) || !prefixes[i + 1]) 54 if (size < (1024LL << 10 * i) || !prefixes[i])
55 { 55 {
56 snprintf(buf, bufsz, "%4lld", size / (unsigned long long)pow(1024LL, i)); 56 snprintf(buf, bufsz, "%4lld", size / (1024 << 10 * (i - 1)));
57 *sz = prefixes[i]; 57 *sz = prefixes[i];
58 return; 58 return;
59 } 59 }
@@ -728,6 +728,7 @@ int
728main(int argc, char **argv) 728main(int argc, char **argv)
729{ 729{
730 char buf[64]; 730 char buf[64];
731 char *path;
731 Eina_List *dirs = NULL, *l; 732 Eina_List *dirs = NULL, *l;
732 Tyls_Options options = {SMALL, EINA_FALSE}; 733 Tyls_Options options = {SMALL, EINA_FALSE};
733 734
@@ -757,13 +758,15 @@ main(int argc, char **argv)
757 if (ee) 758 if (ee)
758 { 759 {
759 int i, cw, ch; 760 int i, cw, ch;
761 int len;
760 char *rp; 762 char *rp;
761 763
762 evas = ecore_evas_get(ee); 764 evas = ecore_evas_get(ee);
763 echo_off(); 765 echo_off();
764 snprintf(buf, sizeof(buf), "%c}qs", 0x1b); 766 snprintf(buf, sizeof(buf), "%c}qs", 0x1b);
765 if (write(0, buf, strlen(buf) + 1) < 0) perror("write"); 767 len = strlen(buf);
766 if (scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4 768 if (write(0, buf, len + 1) < (signed)len + 1) perror("write");
769 if ((scanf("%i;%i;%i;%i", &tw, &th, &cw, &ch) != 4)
767 || (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1)) 770 || (tw <= 0) || (th <= 0) || (cw <= 1) || (ch <= 1))
768 { 771 {
769 echo_on(); 772 echo_on();
@@ -796,8 +799,7 @@ main(int argc, char **argv)
796 { 799 {
797 dirs = eina_list_append(dirs, "./"); 800 dirs = eina_list_append(dirs, "./");
798 } 801 }
799 char *path; 802 EINA_LIST_FREE(dirs, path)
800 EINA_LIST_FOREACH(dirs, l, path)
801 { 803 {
802 if ((rp = ecore_file_realpath(path)) 804 if ((rp = ecore_file_realpath(path))
803 && ecore_file_is_dir(rp)) 805 && ecore_file_is_dir(rp))
@@ -806,9 +808,7 @@ main(int argc, char **argv)
806 free(rp); 808 free(rp);
807 } 809 }
808 } 810 }
809 eina_list_free(dirs);
810 fflush(stdout); 811 fflush(stdout);
811 return 0;
812// ecore_main_loop_begin(); 812// ecore_main_loop_begin();
813 ecore_evas_free(ee); 813 ecore_evas_free(ee);
814 } 814 }