efreet_desktop_string_list_join(Eina_List *list)
{
Eina_List *l;
- const char *tmp;
+ const char *elem;
char *string;
size_t size, pos, len;
string = malloc(size);
pos = 0;
- EINA_LIST_FOREACH(list, l, tmp)
+ EINA_LIST_FOREACH(list, l, elem)
{
- len = strlen(tmp);
+ len = strlen(elem);
/* +1 for ';' */
if ((len + pos + 1) >= size)
{
+ char *tmp;
size = len + pos + 1024;
- string = realloc(string, size);
- if (!string) return NULL;
+ tmp = realloc(string, size);
+ if (!tmp)
+ {
+ free(string);
+ return NULL;
+ }
+ string = tmp;
}
- strcpy(string + pos, tmp);
+ strcpy(string + pos, elem);
pos += len;
strcpy(string + pos, ";");
pos += 1;
{
if (len >= size - 1)
{
+ char *tmp;
+
size = len + 1024;
- exec = realloc(exec, size);
- if (!exec) goto error;
+ tmp = realloc(exec, size);
+ if (!tmp) goto error;
+ exec = tmp;
}
/* XXX handle fields inside quotes? */
command->desktop->orig_path, command->desktop->exec);
if (len >= size - 1)
{
+ char *tmp;
size = len + 1024;
- exec = realloc(exec, size);
- if (!exec) goto error;
+ tmp = realloc(exec, size);
+ if (!tmp) goto error;
+ exec = tmp;
}
exec[len++] = ' ';
exec = efreet_desktop_command_append_multiple(exec, &size,
exec[len++] = '\0';
execs = eina_list_append(execs, exec);
+ exec = NULL;
/* If no file was added, then the Exec field doesn't contain any file
* fields (fFuUdDnN). We only want to run the app once in this case. */
return execs;
error:
- if (execs)
- {
- EINA_LIST_FREE(execs, exec)
- free(exec);
- }
+ IF_FREE(exec);
+ EINA_LIST_FREE(execs, exec)
+ free(exec);
return NULL;
}
while (l > *size - *len)
{
+ char *tmp;
/* we successfully appended this much */
off += *size - *len - 1;
*len = *size - 1;
*size += 1024;
- dest = realloc(dest, *size);
- if (!dest) return NULL;
+ tmp = realloc(dest, *size);
+ if (!tmp)
+ {
+ free(dest);
+ return NULL;
+ }
+ dest = tmp;
*(dest + *len) = '\0';
l = eina_strlcpy(dest + *len, src + off, *size - *len);
{
if (*len >= *size - 1)
{
+ char *tmp;
*size += 1024;
- dest = realloc(dest, *size);
- if (!dest) return NULL;
+ tmp = realloc(dest, *size);
+ if (!tmp)
+ {
+ free(dest);
+ return NULL;
+ }
+ dest = tmp;
}
dest[(*len)++] = c;