kernels/linux-2.4.0/drivers/video/sis/sis_main.c
/* 
 *  Allocates space, return NULL when failed
 */
Allocates space, return NULL when failed
Allocates space return NULL when failed
static struct OH *poh_allocate(unsigned long size)
{
	struct OH *pohThis;
	struct OH *pohRoot;
	int bAllocated = 0;
	if (size > heap.ulMaxFreeSize) {
		DPRINTK("sisfb: Can't allocate %dk size on offscreen\n",
			(unsigned int) size / 1024);
		return (NULL);
	}
	pohThis = heap.ohFree.pohNext;
	while (pohThis != &heap.ohFree) {
		if (size <= pohThis->ulSize) {
			bAllocated = 1;
			break;
		}
		pohThis = pohThis->pohNext;
	}
	if (!bAllocated) {
		DPRINTK("sisfb: Can't allocate %dk size on offscreen\n",
			(unsigned int) size / 1024);
		return (NULL);
	}
	if (size == pohThis->ulSize) {
		pohRoot = pohThis;
		delete_node(pohThis);
	} else {
		pohRoot = poh_new_node();
		if (pohRoot == NULL) {
			return (NULL);
		}
		pohRoot->ulOffset = pohThis->ulOffset;
		pohRoot->ulSize = size;
		pohThis->ulOffset += size;
		pohThis->ulSize -= size;
	}
	heap.ulMaxFreeSize -= size;
	pohThis = &heap.ohUsed;
	insert_node(pohThis, pohRoot);
	return (pohRoot);
}
static struct OH * poh_allocate ( unsigned long size ) { struct OH * pohThis ; struct OH * pohRoot ; int bAllocated = 0 ; if ( size > heap . ulMaxFreeSize ) { DPRINTK ( " \n " , ( unsigned int ) size / 1024 ) ; return ( NULL ) ; } pohThis = heap . ohFree . pohNext ; while ( pohThis != & heap . ohFree ) { if ( size <= pohThis -> ulSize ) { bAllocated = 1 ; break ; } pohThis = pohThis -> pohNext ; } if ( ! bAllocated ) { DPRINTK ( " \n " , ( unsigned int ) size / 1024 ) ; return ( NULL ) ; } if ( size == pohThis -> ulSize ) { pohRoot = pohThis ; delete_node ( pohThis ) ; } else { pohRoot = poh_new_node ( ) ; if ( pohRoot == NULL ) { return ( NULL ) ; } pohRoot -> ulOffset = pohThis -> ulOffset ; pohRoot -> ulSize = size ; pohThis -> ulOffset += size ; pohThis -> ulSize -= size ; } heap . ulMaxFreeSize -= size ; pohThis = & heap . ohUsed ; insert_node ( pohThis , pohRoot ) ; return ( pohRoot ) ; }
Allocates space, return NULL when failed
Allocates space return NULL when failed