Too trivail to copyright (pseudo code)
Posted Aug 19, 2003 21:28 UTC (Tue) by
darkonc (guest, #14197)
Parent article:
Why SCO won't show the code
Looking at that chunk of malloc code, it is extremely functional. It is a very straightforward and minimal implemetation of first-fit memory allocation from a free pool.
static struct ( size_t m_size, char *m_addr } *chunk;
While(more chunks){
if current chunk biggern than request {
take what we need out of the chunk
point the pool pointer to the rest of the chunk
adjust the size indicator.
if we're using the entire chunk,{
move this node to the end of the list.
# (so it doesn't block the search) #
} #endif
return pointer }#endif
}#endwhile
# couldn't find a big enough chunk
return(NULL) # error
It would be pretty difficult to produce a tight version of this algorithm without a high degree of duplication. I'd say you might as well cut and paste, because about the only changes that I can see making in a tight implementation would be to change the variable names. You'd be lucky to find 4 meaningful permutations of this algorithim, once you tighten up the code for the kernel.
Try to implement the pseudo code above, and see just how far away you end up.
BTW, this is not part of a block of duplicate code.. This is pretty much the entire thing. If that's the best that they can find, then they're SOL.
If you're not on somebody's shit list, you're not doing anything worthwhile.
(
Log in to post comments)