Advertisement
dsreyes1014

Segfaults with the whole `if/else-if/else-if' statement

May 28th, 2014
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. void
  2. priority_arg_create (gchar *arg)
  3. {
  4. gchar **argvp;
  5. gint argcp;
  6. gint i;
  7. gint j;
  8.  
  9. argvp = get_arg_vector ();
  10. argcp = 0;
  11. i = 0;
  12.  
  13. /* obtain arg count not including the `NULL` terminator. */
  14. while (argvp[argcp])
  15. {
  16. argcp++;
  17. }
  18.  
  19. g_print ("From `rt_priority.c` line 42: %d\n", argcp);
  20.  
  21. /* Here we look for the jack arg `-Px` with the for loop then the if
  22. statement. If it does not exist then we add it to arg vector with
  23. `else/if` statement. */
  24. for (i = 0; i <= argcp + 1; i++)
  25. {
  26. if (g_strcmp0 (argvp[i], arg) == 0)
  27. {
  28. g_print ("From `rt_priority.c` line 51: %d\n", i);
  29.  
  30. break;
  31. }
  32. /* If `priority arg` is found but the number does not match
  33. execute else/if statement. */
  34. else if (strncmp (argvp[i], "-P", 2) == 0)
  35. {
  36. argvp[i] = arg;
  37.  
  38. break;
  39. }
  40. else if (argvp[i] == NULL)
  41. {
  42. g_print ("From `rt_priority.c` line 65\n");
  43.  
  44. /* Add space to arg vector for the jackd arg `-R`. */
  45. argcp = argcp + 1;
  46.  
  47. /* If realtime arg exists then place priority arg right
  48. after that.*/
  49. if ((strncmp (argvp[1], "-r", 2) == 0) ||
  50. (strncmp (argvp[1], "-R", 2) == 0))
  51. {
  52. /* Here we move the args over one to place `-Px` as the
  53. third arg in the vector. */
  54. for (j = argcp; j >= 2; j--)
  55. {
  56. argvp[j] = argvp[j - 1];
  57. }
  58.  
  59. argvp[2] = arg;
  60. }
  61. else
  62. {
  63. /* Here we move the args over one to place `-Px` as the
  64. second arg in the vector. */
  65. for (j = argcp; j >= 1; j--)
  66. {
  67. argvp[j] = argvp[j - 1];
  68. }
  69.  
  70. argvp[1] = arg;
  71. }
  72.  
  73. break;
  74. }
  75. }
  76.  
  77. file_input (argvp, argcp);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement