From: brunobg AT geocities DOT com (Bruno Barberi Gnecco) Newsgroups: comp.os.msdos.djgpp Subject: Trouble with many mallocs and reallocs Date: 9 Aug 1998 09:36:00 -0500 Organization: Newscene Public Access Usenet News Service (http://www.newscene.com/) Lines: 33 Message-ID: <35cdb08e.6406284@news3.newscene.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I'm writing a text editor, and using a pointer to dinamically allocated memory for each line. Everytime a new byte is added or subtracted from the line, realloc is called. Everything works fine until I type some lines. Then the program quits, and returns a problem at malloc (it happens after I press enter, and it doesn't matter how many characters I typed). The stderr is: Exiting due to signal SIGSEGV Page fault at eip=00008824, error=0004 eax=00000004 ebx=00000000 ecx=fffffffc edx=31de7500 esi=00000001 edi=00000001 ebp=00054dc0 esp=00054db8 program=d:/djgpp/creation/editor/editor.exe cs: sel=01f7 base=8305a000 limit=ff7d3fff ds: sel=01ff base=8305a000 limit=ff7d3fff es: sel=01ff base=8305a000 limit=ff7d3fff fs: sel=020f base=00000000 limit=ffffffff gs: sel=020f base=00000000 limit=ffffffff ss: sel=01ff base=8305a000 limit=ff7d3fff Call frame traceback EIPs: 0x00008824 0x00002822 0x00004515 0x00007db6 Debugging it, I find that the error is exactly at the line that allocates memory to a new line (it allocates 1 byte). I'm running the Windows 95 DPMI server. What may be the problem? Is there a better way to allocate memory? Can I use the DPMI functions to allocae memory directly? How? Thanks! P.S.: this editor will be freeware and open-source. As soon as I can make it work well enough to allow some editing, I'll release it. Maybe in one week... "There's never enough time to do all the nothing you want" Bill Watterson Bruno Barberi Gnecco ICQ #1383173 - PGP 5.0i user My other OS is Linux -=- http://graphx.home.ml.org -=- Electric Eng, Poli