Subject: RE: Memory Problem

From: "SHIVENDRA KUMAR" <[email-masked]>
Date: Fri, 14 Mar 2003 20:52:49 +0530

Hi Vladis & Chandani,

My 2 cents!...
Let me define the problem first.
Chandani, You are using a system which has unsigned short set to 16
bits.
So, the maximum value of unsigned short can be just 64k. malloc takes
unsigned short as argument and obviously maximum you can pass in , is
64k.So, the maximum size which can alloc'ed is 64k.

There can be few solutions:
1. There is a limits.h file which defines the max size of various types.
Please check the "long" size max value. If it corresponds to 32 bits,
then you can also configure short as the same max size as long. This
will allow you to malloc more than 64 k in a chunk.
2.If your system still is 16bits, then the other solution is to write
your own small memory manager on top of malloc
My_malloc( number of multiples, 64k)
This call will allocate 64k chunks using malloc and maintain pointers to
each block but, will make it appear to the pgm that all blocks are
contiguous. More details, please check for info about writing a memory
management layer.
3. Look at pgm requmt . Do you really need one chunk. Or, you can do
with multiple chunks. May be you can write a wrapper which can accepts
multiple data blocks of bmp.

Vladis, to an extent you are right that chandani is using an older
system, but, that's not the correct explanation of the problem.

Regards,
shivendra

-----Original Message-----
From: [email-masked] [mailto:[email-masked]] 
Sent: Friday, March 14, 2003 7:30 PM
To: Chandani, Chirag
Cc: [email-masked]
Subject: Re: Memory Problem 

On Fri, 14 Mar 2003 11:33:39 GMT, "Chandani, Chirag"
<[email-masked]>  said:
> I want to allocate about 600K of memory in a C Program where i
> load a .Bmp image but Malloc() doesnt allow allocation of more 
> than 64 K
> Is there some way out

1) Ask on an intro-to-C mailing list.

2) Learn to give relevant information - are you using some Microsoft
software, or are you compiling on a BSD 2.11 system on a PDP-11?  What
error does malloc() return?  What option(s) did you compile with? etc
etc?

3) There's a better-than-even chance that you're compiling on some
broken system where you have to jump through hoops to get rational
memory management. If so, your only long-term real hope is to use
software that actually works.
-- 
				Valdis Kletnieks
				Computer Systems Senior Engineer
				Virginia Tech

---

From: "David J. Aronson" <[email-masked]>
Date: Fri, 14 Mar 2003 11:36:01 -0500

> Chandani, You are using a system which has unsigned short set to 16

Possibly true, but that is not the problem.

The problem is, someone was using the IETF main discussion list as a 
"help me with my very basic programming problem" resource.  IMHO, Valdis 

>> 1) Ask on an intro-to-C mailing list.

Another suggestion would be to read Eric S. Raymond's essay, "How To Ask 
Questions The Smart Way" (which Chanandi definitely did not do), at:

  http://www.catb.org/~esr/faqs/smart-questions.html

Now, I suggest we let this thread die a timely death.

Thanks,
Dave

-- 
David J. Aronson, Software Engineer for hire in Washington DC area.
See http://destined.to/program/ for online resume, references, etc.