# HG changeset patch # User Masataka Kohagura # Date 1385459826 -32400 # Node ID 7245548995a89825c1f45f64681864fb431dbdea # Parent a96cf4e50524d89cc5a881ab87e265bd3b6dfff1 refactoring in string_args diff -r a96cf4e50524 -r 7245548995a8 example/string_args/main.cc --- a/example/string_args/main.cc Tue Nov 26 17:46:05 2013 +0900 +++ b/example/string_args/main.cc Tue Nov 26 18:57:06 2013 +0900 @@ -23,11 +23,11 @@ for (int i = 1; argv[i]; ++i) { if (strcmp(argv[i], "-cpu") == 0) { - spe_num = atoi(argv[i+1]); + spe_num = atoi(argv[i+1]); i++; } else if (strcmp(argv[i], "-sw") == 0) { - search_word = argv[i+1]; + search_word = argv[i+1]; i++; } else if (strcmp(argv[i], "-t") == 0) { - task_num = atoi(argv[i+1]); + task_num = atoi(argv[i+1]); i++; } } @@ -58,18 +58,11 @@ int TMmain(TaskManager *manager, int argc, char *argv[]) { - char *search_word = 0; - int search_word_len = 0; - - search_word = init(argc,argv); - search_word_len = strlen((const char*)search_word); + const char *search_word = init(argc,argv); + int search_word_len = strlen(search_word); - if (search_word < 0) { - return -1; - } - char *sword = (char*)manager->allocate(sizeof(char)*search_word_len); - //strcpy(sword,(const char*)search_word); - memcpy(sword,(const char*)search_word,search_word_len); + char *sword = (char*)manager->allocate(search_word_len+1); + memcpy(sword,search_word,search_word_len); // to get correct alignment task_init(); run_start(manager, sword, search_word_len); diff -r a96cf4e50524 -r 7245548995a8 example/string_args/ppe/Exec.cc --- a/example/string_args/ppe/Exec.cc Tue Nov 26 17:46:05 2013 +0900 +++ b/example/string_args/ppe/Exec.cc Tue Nov 26 18:57:06 2013 +0900 @@ -18,7 +18,7 @@ static int run(SchedTask *s, void *rbuf, void *wbuf) { - char *search_word = (char *)s->get_input(rbuf,0); + const char *search_word = (char *)s->get_input(rbuf,0); long task_size = (long)s->get_param(0);