Mail Archives: djgpp/1999/06/08/05:53:07
X-Authentication-Warning: | mail.bio.uva.nl: Host biomacI-138.bio.uva.nl [145.18.167.138] claimed to be [145.18.167.138]
|
Message-Id: | <v01540b01b38298fc354a@[145.18.167.138]>
|
Mime-Version: | 1.0
|
Date: | Tue, 8 Jun 1999 11:55:28 +0200
|
To: | djgpp AT delorie DOT com
|
From: | dlanor AT dds DOT nl (Dlanor Blytkerchan)
|
Subject: | Re: malloc() problem
|
Reply-To: | djgpp AT delorie DOT com
|
>> > What does go32-v2 print out? And what OS and DPMI server do you use?
>> The above memory value (the 4 MB) is taken from go32-v2
>If you ran go32-v2 *before* invoking your program, it is possible that
>the programn's code, data and stack used up quite a lot of memory, and
>you really don't have 34KB left.
In this case, that's hard to imagine: all it does is call a method from
main(), which allocates the 34 kb using malloc() and tries to open a file.
After that, it frees the buffer and closes the file again. I've had DJGPP
programs do much more in this amount of memory, so I really don't think
it's a lack of memory I'm seeing here. There are only a few global
variables, all of which are either pointers or ints. The sum total of those
isn't more than 100 bytes (one pointer to the file handle, one bool (rc)
and one pointer to the buffer I'm trying to allocate, plus the globals from
the headers).
This is the first time I'm using malloc() from DJGPP. The same code does
work from Borland C - and does exactly what it's supposed to do. It is also
very similar to code used in programs by other programmers, which does work
in DJGPP. That's why I said I though this to be "weird" little problem.
I have found a way of getting memory in dpmi.h. however, the address of
that memory is returned inside an info structure as an int. What I do not
know is how to use my pointers to point to the place that int is pointing
at. That might help.
>(4MB is quite low for running DJGPP programs anyway.)
That may be, but it'll have to do for now ;-)
>Try invoking go32-v2 (via `system') at the beginning of `main', or near
>the place where you allocate those 34KB, and see what does it print then.
I'll do that, but I doubt it will change anything: I simply see no reason
for the program to use 4MBs of memory just for allocating 34 K of mem and
opening a file. (I'll do it when I'm near that computer again: it's about
20 miles from here)
One interesting thingy, though: the same type of error occured earlier when
making this program: I had defined the same buffer not as a pointer, but as
bufferType buffer;. When I started the program it died with "Load error: no
DPMI memory".
As for system stuff: I'm using DOS 6.22 dutch edition with QEMM and HIMEM
alternatively (it doesn't work under either). The system itself is a 386
(don't laugh!), which is the minimal target system for my programs (i.e.:
what I write must run on this computer, and all computers better than this
one. Hence, I write on this computer, and do other stuff on other
computers).
I do my DJGPP programming from RHIDE (newest version always), even though
I'm not too thrilled with some of the frills this particular IDE exhibits.
That's about all the relevant info I can think of.
The error occurs wether or not RHIDE is active - that doesn't matter.
If you have any ideas (like for converting that int from the info struct to
a usable pointer), I'd be much obliged. (In the mean time, I'll be killing
some coli here at the university ;->)
Greetz!
Dlanor
- Raw text -