SunQuest
           C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old April 2nd, 2003, 02:26 AM
anbarasu anbarasu is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: india
Posts: 42 anbarasu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
memory allocation

hai friends,

my project needs allocating the memory in particular segment,how can i acheive it?.

malloc and calloc i tried.

please suggest me

thanks in advance

Reply With Quote
  #2  
Old April 2nd, 2003, 09:38 AM
dwise1_aol's Avatar
dwise1_aol dwise1_aol is offline
Contributing User
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jan 2003
Location: USA
Posts: 3,803 dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)dwise1_aol User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 1 Month 11 h 57 m 9 sec
Reputation Power: 437
Memory allocation via malloc et al. is from the heap, which is an area of memory allocated to the program at startup and the location of which you cannot predict nor specify (normally) when you write the program.

Are you actually needing to allocate memory in that particular segment? Or are you really talking about having to set a pointer to point to a particular physical address?

For a flat memory model (eg, an ARM processor), we memory-mapped our FPGA hardware registers to start at a specific memory address thus:
Code:
#define FPGA_BASE       (0x00C00000)
#define patFPGABASE  ((STRUCTFPGA*)FPGA_BASE)
// STRUCTFPGA was previously defined as a struct whose elements are the hardware registers

From that point on, patFPGABASE is used as a pointer to those registers. Of course, we could have just as easily declared a pointer variable and assigned the starting address to it:

Code:
#define FPGA_BASE       (0x00C00000)
STRUCTFPGA* patFPGABASE;
patFPGABASE = (STRUCTFPGA*)FPGA_BASE;


Judging from your reference, "memory in particular segment", you are programming on an Intel machine under Windows. In that case, Microsoft Visual C++ provides a function macro, MK_FP, to "make a far pointer":
Quote:
From the VC++ 1.52 Help on MK_FP:

_MK_FP

#include <dos.h>

Syntax void __far *_MK_FP( unsigned seg, unsigned offset );
Parameter Description
seg Segment value for pointer
offset Offset value for pointer

The _MK_FP macro makes a far pointer from the segment value, seg, and the offset value, offset.

Return Value

The _MK_FP macro returns the resulting far pointer.

This was under Win16. There might be more support for this under Win32.

Of course, if you are trying to do something entirely different, then please describe it and mention what system (OS & C development environment).

Last edited by dwise1_aol : April 2nd, 2003 at 09:41 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > memory allocation


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway