Segmentation Fault

G

Galvin Burgos

Guest
Hello everyone! I'm having a bit of an issue with an application that I wrote. The particular issue is a segmentation fault.

My application first filters names out of a text file and puts them in a dynamically allocated buffer with each name being terminated with a NULL character. Then an array of character pointers is created with each element of the array pointing to one of the names in the buffer effectively creating and array of strings. Then the application performs a merge sort on the array of strings. The application uses an additional thread to sort the top half of the array of strings while the main thread sorts the bottom half. Now the issue is that the application works perfectly fine when the file is around 33MB, but if the file is about 34MB or 35MB it produces a segmentation fault when it attempts to sort the list.
The segmentation fault occurs when the final Merge_t() operation attempts to populate array2


I'm working on a laptop with 1GB of memory installed so i'm wondering if maybe my system ran out of memory because the merge sort takes a recursive approach but with virtual memory I can't see how that would be the problem.

utillib.c.txt --> functions to filter names from names.txt file and create a list of names as an array of strings.
utillib.h.txt --> function prototypes for utillib.c.txt
MergeSortLib.c.txt --> functions that implement the merge sort algorithm
MergeSortLib.h.txt --> function prototypes for MergeSortLib.h.txt

I greatly appreciate any help given!!
 

Attachments

  • utillib.h.txt
    356 bytes · Views: 932
  • makefile.txt
    310 bytes · Views: 823
  • MergeSortLib.c.txt
    3.3 KB · Views: 985
  • MergeSortLib.h.txt
    346 bytes · Views: 929
  • names.txt
    150.3 KB · Views: 1,019


Latest posts

Top