get_eventfile_abspath(): minor improvement: get rid of strcpy etc.
This commit is contained in:
parent
bd9bcd8752
commit
b9a638d43f
24
adhocify.c
24
adhocify.c
@ -374,16 +374,20 @@ char *get_eventfile_abspath(struct inotify_event *event)
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
size_t nameLen = strlen(event->name);
|
|
||||||
char *abspath = xmalloc((strlen(wdpath) + nameLen + 2) * sizeof(char));
|
|
||||||
strcpy(abspath, wdpath);
|
|
||||||
if(nameLen > 0)
|
|
||||||
{
|
|
||||||
strcat(abspath, "/");
|
|
||||||
strcat(abspath, event->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return abspath;
|
char *result = NULL;
|
||||||
|
if(event->name != NULL && *event->name != 0)
|
||||||
|
{
|
||||||
|
if(asprintf(&result, "%s/%s", wdpath, event->name) == -1)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = strdup(wdpath);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -484,7 +488,7 @@ void parse_options(int argc, char **argv)
|
|||||||
int option;
|
int option;
|
||||||
int option_index;
|
int option_index;
|
||||||
uint32_t optmask = 0;
|
uint32_t optmask = 0;
|
||||||
while((option = getopt_long(argc, argv, "absdo:w:r:m:l:i:e::", long_options, &option_index)) != -1)
|
while((option = getopt_long(argc, argv, "absdo:w:m:l:i:e::", long_options, &option_index)) != -1)
|
||||||
{
|
{
|
||||||
switch(option)
|
switch(option)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user