X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=blobdiff_plain;f=tests%2Ftest_sessions.c;h=3e876c88990c15cc1dbb14a9a98be1bfea202ceb;hp=f444e30438bb3aeff3a3d9ee54531788b40aeb79;hb=986122407a4279879094329dbfc19187f4a65faf;hpb=441c16a7f0bbab56a5e783059d0cddab68544a9a diff --git a/tests/test_sessions.c b/tests/test_sessions.c index f444e3043..3e876c889 100644 --- a/tests/test_sessions.c +++ b/tests/test_sessions.c @@ -37,6 +37,7 @@ #define PATH1 "/tmp/.test-junk-lttng" #define MAX_SESSIONS 10000 +#define RANDOM_STRING_LEN 11 /* * String of 263 caracters. NAME_MAX + "OVERFLOW". If OVERFLOW appears in the @@ -61,22 +62,23 @@ static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz"; +static char random_string[RANDOM_STRING_LEN]; /* * Return random string of 10 characters. + * Not thread-safe. */ static char *get_random_string(void) { int i; - char *str = malloc(11); - for (i = 0; i < 10; i++) { - str[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; + for (i = 0; i < RANDOM_STRING_LEN - 1; i++) { + random_string[i] = alphanum[rand() % (sizeof(alphanum) - 1)]; } - str[10] = '\0'; + random_string[RANDOM_STRING_LEN - 1] = '\0'; - return str; + return random_string; } /*