Subject:
|
Re: Question about mm.C in BrickOS
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Sun, 14 Sep 2003 21:43:17 GMT
|
Viewed:
|
3161 times
|
| |
| |
In lugnet.robotics.rcx.legos, Michael Obenland wrote:
> > 6 next=ptr+size+1;
>
> Next points behind the allocated block.
Michael I was reading through your reply you sent me a while back and I don't
understand what that line in the code does and you explaination of it. I don't
understand what is meant by pointing behind the block. Any help would be great
thanks.
Here is the original block of code:
============
1 if(*ptr>=size) { // big enough?
2 *(ptr-1)=(size_t)ctid; // set owner
3
4 // split this block?
5 if((*ptr-size)>=MM_SPLIT_THRESH) {
6 next=ptr+size+1;
7 *(next++)=MM_FREE;
8 *(next)=*ptr-size-MM_HEADER_SIZE;
9 mm_try_join(next);
10
11 *ptr=size;
12 }
===========
|
|
Message has 1 Reply: | | Re: Question about mm.C in BrickOS
|
| (...) +---- +------+---...---+--...-+-------- | pid | size | data..... | pid | size | data... *-----+------+---......-+-------- ^ +---...--- ptr points to that address. This is the memory layout for the data allocation pool. Pid is the process id of (...) (21 years ago, 15-Sep-03, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | Re: Question about mm.C in BrickOS
|
| Hi, (...) Ptr points to the length byte of the first free block (...) *(ptr-1) actually is MM_FREE and is now set to the callers id. (...) Now we can do two things: We could grab all memory we found in this block or we could allocate only the memory (...) (21 years ago, 13-Aug-03, to lugnet.robotics.rcx.legos)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|