Thread View: comp.os.os2.programmer
2 messages
2 total messages
Started by BEEBE,GARY E
Thu, 28 Jan 1993 14:53
Problems with realloc
Author: BEEBE,GARY E
Date: Thu, 28 Jan 1993 14:53
Date: Thu, 28 Jan 1993 14:53
33 lines
1937 bytes
1937 bytes
Good Morning,
I am having a bit of trouble with realloc. I am doing a bit of program
development on a PS/2 Mod 70 E61 w/320 ext. SCSI. I have 16M ram. The
program must read a file of unknown length, a line at a time, store
(and find) an unknown number of sets of a uniquely formatted data. I have
compiled and linked the C program with the C Set/2 compiler (CSD level 0028)
and linker. With the warning level set to "info", I get no errors or warnings.
This program is non-PM based at this time. I pass it the file name and it
is to go off and read all the data and store it in an array of pointers to
pointers to the previously defined data structure.
The code works flawlessly until I read the 78th data entry. I then get an error
(and stack dump) saying that malloc generated a protection violation. I
stepped the program to the 77 data entry in the debugger. All data variables
look fine, I have no outside indications of any impending disaster. When I
step past the line that reallocates memory for the next data entry...death!
If I didn't know any better, I'd suspect that realloc is trying to allocate
a new segment for more data and failing. But, we now have a flat memory model
right? I'm at a loss. This is a serious show stopper. I must be able to calloc
and realloc data items that can grow to greater than 64K.
If anyone has any suggestions on how to resolve this please e-mail me a note.
Thanz
--
BEEBE,GARY E
Georgia Institute of Technology, Atlanta Georgia, 30332
uucp: ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gb8
Internet: gb8@prism.gatech.edu
Problems with realloc
Author: Ian Ameline
Date: Thu, 28 Jan 1993 22:23
Date: Thu, 28 Jan 1993 22:23
32 lines
2047 bytes
2047 bytes
In article <82201@hydra.gatech.EDU>, gb8@prism.gatech.EDU (BEEBE,GARY E) writes: > >Good Morning, > >I am having a bit of trouble with realloc. I am doing a bit of program >development on a PS/2 Mod 70 E61 w/320 ext. SCSI. I have 16M ram. The >program must read a file of unknown length, a line at a time, store >(and find) an unknown number of sets of a uniquely formatted data. I have >compiled and linked the C program with the C Set/2 compiler (CSD level 0028) >and linker. With the warning level set to "info", I get no errors or warnings. >This program is non-PM based at this time. I pass it the file name and it >is to go off and read all the data and store it in an array of pointers to >pointers to the previously defined data structure. >The code works flawlessly until I read the 78th data entry. I then get an error >(and stack dump) saying that malloc generated a protection violation. I >stepped the program to the 77 data entry in the debugger. All data variables >look fine, I have no outside indications of any impending disaster. When I >step past the line that reallocates memory for the next data entry...death! > >If I didn't know any better, I'd suspect that realloc is trying to allocate >a new segment for more data and failing. But, we now have a flat memory model >right? I'm at a loss. This is a serious show stopper. I must be able to calloc >and realloc data items that can grow to greater than 64K. > Try using the debug alloc functions to track down what's going on. It sounds like you're corrupting malloc's heaps. See Chapter 13 in the C-Set/2 User's guide. Regards, Ian.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads