473,320 Members | 1,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Memory allocation based on a big array

I would be interested to get code to do memory allocation and management,
just as malloc and friends do, but using a predefined memory pool - for
example, a sufficiently large global array. I do not want to reinvent the
wheel, for I am sure this must exist already. However, a quick Google
search did not return anything obvious. Maybe somebody in this group knows
better?
Oct 28 '06 #1
4 2513
"Frank W. Steiner" wrote:
>
I would be interested to get code to do memory allocation and
management, just as malloc and friends do, but using a predefined
memory pool - for example, a sufficiently large global array. I do
not want to reinvent the wheel, for I am sure this must exist
already. However, a quick Google search did not return anything
obvious. Maybe somebody in this group knows better?
See the debug mechanisms in nmalloc.zip, using fakesbrk. Initial
development was done using this. See:

<http://cbfalconer.home.att.net/download/>

--
Some informative links:
<news:news.announce.newusers
<http://www.geocities.com/nnqweb/>
<http://www.catb.org/~esr/faqs/smart-questions.html>
<http://www.caliburn.nl/topposting.html>
<http://www.netmeister.org/news/learn2quote.html>
<http://cfaj.freeshell.org/google/>
Oct 28 '06 #2
On Sat, 2006-10-28 at 15:02 +0000, Frank W. Steiner wrote:
I would be interested to get code to do memory allocation and management,
just as malloc and friends do, but using a predefined memory pool - for
example, a sufficiently large global array. I do not want to reinvent the
wheel, for I am sure this must exist already. However, a quick Google
search did not return anything obvious. Maybe somebody in this group knows
better?
I believe that K&R has a version of what you want near the end of
Chapter 8. That's a pretty UNIX-y chapter, though; it might not be
fully Standard C.

There's also a discussion of dynamic storage allocation in Section 2.5
of The Art of Computer Programming, Volume 1, Third Edition by Donald
Knuth. If you expect to learn much from it, prepare to spend a month or
so on just that section.

Happy coding!

--
Andrew Poelstra <http://www.wpsoftware.net/projects/>

Oct 28 '06 #3
On Sat, 28 Oct 2006 11:42:57 -0400, CBFalconer <cb********@yahoo.com>
wrote:
>"Frank W. Steiner" wrote:
>>
I would be interested to get code to do memory allocation and
management, just as malloc and friends do, but using a predefined
memory pool - for example, a sufficiently large global array. I do
not want to reinvent the wheel, for I am sure this must exist
already. However, a quick Google search did not return anything
obvious. Maybe somebody in this group knows better?

See the debug mechanisms in nmalloc.zip, using fakesbrk. Initial
development was done using this. See:

<http://cbfalconer.home.att.net/download/>
nmalloc.c(73) : Error 322: Unable to open include file 'unistd.h'

--
jay
Oct 29 '06 #4
jaysome wrote:
CBFalconer <cb********@yahoo.comwrote:
>"Frank W. Steiner" wrote:
>>>
I would be interested to get code to do memory allocation and
management, just as malloc and friends do, but using a predefined
memory pool - for example, a sufficiently large global array. I do
not want to reinvent the wheel, for I am sure this must exist
already. However, a quick Google search did not return anything
obvious. Maybe somebody in this group knows better?

See the debug mechanisms in nmalloc.zip, using fakesbrk. Initial
development was done using this. See:

<http://cbfalconer.home.att.net/download/>

nmalloc.c(73) : Error 322: Unable to open include file 'unistd.h'
You are not setting the appropriate debug constants. When that is
done it will use 'fakesbrk' instead, and you can exercise it
through the testing mechanism. I think. Possibly you are running
into the use of write in the debug mechanisms. At any rate, the
point was to read the code and see how fakesbrk could supply the
fundamental storage involved. nmalloc is designed for DJGPP, and
naturally has to be system dependent. The non-standard mechanisms
are minimized, so that the only unusual reliance is on sbrk in the
operational system. The debuggery uses write rather than fwrite,
because in action it has to function (in DJGPP) before the file
system has been initialized.

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>
Oct 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Michael B. Allen | last post by:
Coming from C and Java on *nix I'm a little out of my element messing around with CList and MSVC++ but I think my issues are largely syntactic. I have an ADT that I use called a 'varray' that can...
9
by: CptDondo | last post by:
I am working on an embedded platform which has a block of battery-backed RAM. I need to store various types of data in this block of memory - for example, bitmapped data for control registers,...
13
by: xian_hong2046 | last post by:
Hello, I think dynamic memory allocation is supposed to be used when one doesn't know in advance how much memory to allocate until run time. An example from Thinking in C++ is to dynamically...
74
by: ballpointpenthief | last post by:
If I have malloc()'ed a pointer and want to read from it as if it were an array, I need to know that I won't be reading past the last index. If this is a pointer to a pointer, a common technique...
7
by: toton | last post by:
Hi, I have a STL vector of of characters and the character class has a Boost array of points. The things are vector<Characterchars; and class Character{ private: array<Point,Npoints; }; Now...
81
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
34
by: jacob navia | last post by:
Suppose that you have a module that always allocates memory without ever releasing it because the guy that wrote it was lazy, as lazy as me. Now, you want to reuse it in a loop. What do you do?...
11
by: Bryan Parkoff | last post by:
I want to know how much static memory is limited before execution program starts. I would write a large array. The large array has 65,536 elements. The data size is double word. The static...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.