How can i do partition pf the memory like partition0 has 50kbytes, partition1 has next 50 kbytes like that.. how can i do using C programming.
How can i do partition pf the memory like partition0 has 50kbytes, partition1 has next 50 kbytes like that.. how can i do using C programming.
What do you actually want to do?
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
i want to do partition in the space available in memory into some 3 or 4 partitions, whose size will be 50 kbytes each...
1. Develop a data structure, such as a linked list:
2. Allocate the block sizes you need.Code:struct block { void * mem; size_t memlen; struct block * mem; ];
Success. RAM has been partitioned enough to suit your needs, and organized so that you may access it. Malloc can actually give you more than you ask for (I imagine that most implementations of malloc like to employ a simpler scheme, like fragmenting memory at word boundaries or at byte sizes that are powers of two).
A typical example of ...cheap programming practices.Code:... goto johny_walker_red_label; johny_walker_blue_label: exit(-149$); johny_walker_red_label : exit( -22$);
can i allocate using malooc function?
sorry "malloc" function...
I'm still not sure what you want to do, but yes, you should be able to allocate blocks of 50KB at a time with malloc.
Partition to me means that there is some sort of "wall" between the memory blocks, enforced by hardware preferably, which the above solution doesn't provide.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
You can allocate using any function designed for that purpose.
malloc: Allocate but not initialize
use:
calloc: Allocate and set to zero sized objects.Code:#include <stdlib.h> ... void *mem; mem = malloc(1024); /* 1024 bytes uninitialized */
use:
Code:#include <stdlib.h> struct foo { int bar; char foobar[64]; }; int main() { struct foo *lot_of_foo; lot_of_foo = calloc(sizeof(struct foo), 100); /* 100 foo's, and their memory 0 */ }
A typical example of ...cheap programming practices.Code:... goto johny_walker_red_label; johny_walker_blue_label: exit(-149$); johny_walker_red_label : exit( -22$);