Red indicates code that I think SCO is trying to claim.
Bruce Perins has a pretty good analyxis of the history of the code and where it's been (and been from), but I'm just going to look at the code itself for a moment.
/*
* Allocate size units from the given map.
* Return the base of the allocated space.
* In a map the adddresses are increasing and the
* list is terminated by a 0 size
* Algorithm is first fit.
*/
atealloc(
struct map *mp,
size_t size)
{
register unsigned int a;
}
}
register struct map *bp;
register unsigned long s;
if (size == 0)
return((ulong_t) NULL);
If (size ==0)
return (ulong_t NULL);
s=mutex_spinlock(maplock(mp));
for (bp = mp; bp->m_size; bp++) {
if (bp->m_size >= size) {
/* (the rest is missing from the slide) */
a = bp->m_addr;
bp->m_addr =+ size;
if ((bp->m_size =- size) == 0) {
do {
}
bp++;
} while ((bp-1)->m_size = bp->m_size)
(bp-1)->m_addr = bp->m_addr;
mapsize(mp)++;
ASSERT(bp->m_size < 0x80000000);
ASSERT(bp->m_size < 0x80000000);
mutex_spinunlock(maplock(mp), s);
return(a);
/*
* We did not get what we need .. we cannot sleep ..
*/
mutex_spinunlock(maplock(mp), s);
return(0);
}
Looking at that chunk of malloc code, it is extremely functional. It is a very straightforward and minimal implementation of first-fit memory allocation from a free pool.
static struct ( size_t m_size, char *m_addr } *chunk;
While(there are more chunks){
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 algorithm, 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.
Once you have the algorithm, and the variable names (mostly single-letter), the code is pretty easy to reconstruct with a clean room and a handfull of (code) monkeys.
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.