home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Club Amiga de Montreal - CAM
/
CAM_CD_1.iso
/
files
/
568b.lha
/
PowerSource_v3.0
/
source.lzh
/
source
/
sbord.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-15
|
2KB
|
89 lines
/*----------------------------------------------------------------------*
sbord.c version 3.0 - © Copyright 1991 Jaba Development
Author : Jan van den Baard
Purpose: Shared Borders routines.
*----------------------------------------------------------------------*/
extern struct MemoryChain Memory;
struct BorderList SBorders;
struct SharedBorder *CreateSBorder( struct Border *brd )
{
struct SharedBorder *sbrd;
if(NOT(sbrd = (struct SharedBorder *)Alloc(&Memory,sizeof(struct SharedBorder))))
return NULL;
sbrd->UseCount = 1;
sbrd->Border = brd;
AddTail((void *)&SBorders,(void *)sbrd);
return(sbrd);
}
struct SharedBorder *FindSBorder( register struct Border *brd )
{
register struct SharedBorder *tmp;
for(tmp = SBorders.Head; tmp->Border != brd; tmp = tmp->Succ) {
if(NOT tmp->Succ)
return(NULL);
}
return(tmp);
}
void AddUser( struct Border *brd )
{
struct SharedBorder *tmp;
if(NOT (tmp = FindSBorder(brd))) return;
tmp->UseCount++;
}
void RemUser( struct Border *brd )
{
register struct Border *b, *b1;
struct SharedBorder *tmp;
if(NOT (tmp = FindSBorder(brd))) return;
tmp->UseCount--;
if(NOT tmp->UseCount) {
b = tmp->Border;
while(1) {
b1 = b->NextBorder;
if(NOT TestBits((ULONG)tmp->SpecialFlags,SB_HIGHBORDER))
FreeItem(&Memory,b->XY,(b->Count << 2));
FreeItem(&Memory,b,sizeof(struct Border));
if(NOT(b = b1)) break;
}
Remove((void *)tmp);
FreeItem(&Memory,tmp,sizeof(struct SharedBorder));
}
}
ULONG Account( register struct Border *brd )
{
register struct SharedBorder *tmp;
register ULONG acc = 0L;
for( tmp = SBorders.Head; tmp->Border != brd; tmp = tmp->Succ, acc++);
return(acc);
}
struct Border *GetBorder( ULONG acc )
{
register struct SharedBorder *tmp;
register ULONG num = 0L;
for(tmp = SBorders.Head; num != acc; tmp = tmp->Succ, num++);
return(tmp->Border);
}