Remove PATH_MAX use.
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 23 Dec 2008 13:12:06 +0000 (13:12 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Tue, 23 Dec 2008 13:12:06 +0000 (13:12 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eina@38288 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/include/eina_private.h
src/lib/eina_benchmark.c
src/lib/eina_module.c

index ea266cc..bf644aa 100644 (file)
 #include "eina_iterator.h"
 #include "eina_accessor.h"
 
-#ifndef PATH_MAX
-# define PATH_MAX 4096
-#endif
-
 #ifndef MIN
 # define MIN(x, y) (((x) > (y)) ? (y) : (x))
 #endif
index ef03761..565c10f 100644 (file)
@@ -292,6 +292,8 @@ eina_benchmark_register(Eina_Benchmark *bench, const char *name, Eina_Benchmark_
  * immediatly. Otherwise, it returns the list of the names of each
  * test.
  */
+#define EINA_BENCHMARK_FILENAME_MASK "bench_%s_%s.gnuplot"
+#define EINA_BENCHMARK_DATA_MASK "bench_%s_%s.%s.data"
 EAPI Eina_Array *
 eina_benchmark_run(Eina_Benchmark *bench)
 {
@@ -299,12 +301,18 @@ eina_benchmark_run(Eina_Benchmark *bench)
    FILE *current_data;
    Eina_Array *ea;
    Eina_Run *run;
-   char buffer[PATH_MAX];
+   char *buffer;
    Eina_Bool first = EINA_FALSE;
+   int length;
 
    if (!bench) return NULL;
 
-   snprintf(buffer, PATH_MAX, "bench_%s_%s.gnuplot", bench->name, bench->run);
+   length = strlen(EINA_BENCHMARK_FILENAME_MASK) + strlen(bench->name) + strlen(bench->run);
+
+   buffer = alloca(sizeof (char) * length);
+   if (!buffer) return NULL;
+
+   snprintf(buffer, length, EINA_BENCHMARK_FILENAME_MASK, bench->name, bench->run);
 
    main_script = fopen(buffer, "w");
    if (!main_script) return NULL;
@@ -336,9 +344,17 @@ eina_benchmark_run(Eina_Benchmark *bench)
      {
        Eina_Counter *counter;
        char *result;
+       int tmp;
        int i;
 
-       snprintf(buffer, PATH_MAX, "bench_%s_%s.%s.data", bench->name, bench->run, run->name);
+       tmp = strlen(EINA_BENCHMARK_DATA_MASK) + strlen(bench->name) + strlen(bench->run) + strlen(run->name);
+       if (tmp > length)
+         {
+            buffer = alloca(sizeof (char) * tmp);
+            length = tmp;
+         }
+
+       snprintf(buffer, length, EINA_BENCHMARK_DATA_MASK, bench->name, bench->run, run->name);
 
        current_data = fopen(buffer, "w");
        if (!current_data) continue ;
index ee59e85..cf35e83 100644 (file)
@@ -107,10 +107,16 @@ static void _dir_list_cb(const char *name, const char *path, void *data)
        if (!strcmp(name + length - strlen(MODULE_EXTENSION),
                        MODULE_EXTENSION))
        {
-               char file[PATH_MAX];
+               char *file;
                Eina_Module *m;
+               int length;
 
-               snprintf(file, PATH_MAX, "%s/%s", path, name);
+               length = strlen(path) + strlen(name) + 2;
+
+               file = alloca(sizeof (char) * length);
+               if (!file) return ;
+
+               snprintf(file, length, "%s/%s", path, name);
                m = eina_module_new(file);
                if (!m)
                        return;