資源簡介
飛思卡爾攝像頭專用顯示工具,體積小,質量輕,非常合適

代碼片段和文件信息
/*
?*?File:????????alloc.c
?*?Purpose:?????generic?malloc()?and?free()?engine
?*
?*?Notes:???????99%?of?this?code?stolen/borrowed?from?the?K&R?C
?*??????????????examples.
?*
?*/
#include?“common.h“
#include?“stdlib.h“
#pragma?section?=?“HEAP“
/********************************************************************/
/*
?*?This?struct?forms?the?minimum?block?size?which?is?allocated?and
?*?also?forms?the?linked?list?for?the?memory?space?used?with?alloc()
?*?and?free().??It?is?padded?so?that?on?a?32-bit?machine?all?malloc‘ed
?*?pointers?are?16-byte?aligned.
?*/
typedef?struct?ALLOC_HDR
{
????struct
????{
????????struct?ALLOC_HDR?????*ptr;
????????unsigned?int?size;
????}?s;
????unsigned?int?align;
????unsigned?int?pad;
}?ALLOC_HDR;
static?ALLOC_HDR?base;
static?ALLOC_HDR?*freep?=?NULL;
/********************************************************************/
void
free?(void?*ap)
{
????ALLOC_HDR?*bp?*p;
????bp?=?(ALLOC_HDR?*)ap?-?1;???/*?point?to?block?header?*/
????for?(p?=?freep;?!((bp?>?p)?&&?(bp?s.ptr))?;?p?=?p->s.ptr)
????{
????????if?((p?>=?p->s.ptr)?&&?((bp?>?p)?||?(bp?s.ptr)))
????????{
????????????break;?/*?freed?block?at?start?or?end?of?arena?*/
????????}
????}
????if?((bp?+?bp->s.size)?==?p->s.ptr)
????{
????????bp->s.size?+=?p->s.ptr->s.size;
????????bp->s.ptr?=?p->s.ptr->s.ptr;
????}
????else
????{
????????bp->s.ptr?=?p->s.ptr;
????}
????if?((p?+?p->s.size)?==?bp)
????{
????????p->s.size?+=?bp->s.size;
????????p->s.ptr?=?bp->s.ptr;
????}
????else
????{
????????p->s.ptr?=?bp;
????}
????freep?=?p;
}
/********************************************************************/
void?*
malloc?(unsigned?nbytes)
{
????/*?Get?addresses?for?the?HEAP?start?and?end?*/
#if?(defined(CW))
??????extern?char?__HEAP_START;
??????extern?char?__HEAP_END[];
????#elif?(defined(IAR))
??????char*?__HEAP_START?=?__section_begin(“HEAP“);
??????char*?__HEAP_END?=?__section_end(“HEAP“);
????#endif
???
????ALLOC_HDR?*p?*prevp;
????unsigned?nunits;
????nunits?=?((nbytes+sizeof(ALLOC_HDR)-1)?/?sizeof(ALLOC_HDR))?+?1;
????if?((prevp?=?freep)?==?NULL)
????{
????????p?=?(ALLOC_HDR?*)__HEAP_START;
????????p->s.size?=?(?((uint32)__HEAP_END?-?(uint32)__HEAP_START)
????????????/?sizeof(ALLOC_HDR)?);
????????p->s.ptr?=?&base;
????????base.s.ptr?=?p;
????????base.s.size?=?0;
????????prevp?=?freep?=?&base;
????}
????for?(p?=?prevp->s.ptr;?;?prevp?=?p?p?=?p->s.ptr)
????{
????????if?(p->s.size?>=?nunits)
????????{
????????????if?(p->s.size?==?nunits)
????????????{
????????????????prevp->s.ptr?=?p->s.ptr;
????????????}
????????????else
????????????{
????????????????p->s.size?-=?nunits;
????????????????p?+=?p->s.size;
????????????????p->s.size?=?nunits;
????????????}
????????????freep?=?prevp;
????????????return?(void?*)(p?+?1);
????????}
????????if?(p?==?freep)
????????????return?NULL;
????}
}
/*******************************************
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????2030??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\128KB_Pflash.icf
?????文件???????2206??2010-11-11?14:41??OLED附送資料\OLED-K60\build\config?files\128KB_Pflash_128KB_Dflash.icf
?????文件???????2034??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\128KB_Ram.icf
?????文件???????2030??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\256KB_Pflash.icf
?????文件???????2214??2010-11-11?14:41??OLED附送資料\OLED-K60\build\config?files\256KB_Pflash_256KB_Dflash.icf
?????文件???????2024??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\32KB_Ram.icf
?????文件???????2041??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\512KB_Pflash.icf
?????文件???????2217??2010-11-11?14:41??OLED附送資料\OLED-K60\build\config?files\64KB_Pflash_64KB_Dflash.icf
?????文件???????2024??2010-10-27?14:30??OLED附送資料\OLED-K60\build\config?files\64KB_Ram.icf
?????文件????????305??2010-10-01?13:03??OLED附送資料\OLED-K60\build\iar.h
?????文件??????23095??2013-01-13?23:31??OLED附送資料\OLED-K60\Debug\Exe\DEMOK_Kinetis_GPIO_Example.hex
?????文件?????187292??2013-01-13?23:31??OLED附送資料\OLED-K60\Debug\Exe\DEMOK_Kinetis_GPIO_Example.out
?????文件??????27632??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\adc.o
?????文件??????12072??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\alloc.o
?????文件??????17536??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\arm_cm4.o
?????文件???????8680??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\assert.o
?????文件???????1920??2012-11-10?22:21??OLED附送資料\OLED-K60\Debug\Obj\crt0.o
?????文件???????9580??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\delay.o
?????文件???????3661??2013-01-16?22:25??OLED附送資料\OLED-K60\Debug\Obj\DEMOK_Kinetis_GPIO_Example.pbd
?????文件???????8712??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\exti.o
?????文件??????22900??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\FTM.o
?????文件??????18628??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\gpio.o
?????文件??????10664??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\io.o
?????文件???????3908??2013-01-09?19:02??OLED附送資料\OLED-K60\Debug\Obj\isr.o
?????文件???????7672??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\lptmr.o
?????文件??????70692??2013-01-13?23:19??OLED附送資料\OLED-K60\Debug\Obj\LQ12864.o
?????文件???????9796??2013-01-13?23:31??OLED附送資料\OLED-K60\Debug\Obj\main.o
?????文件??????14104??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\mcg.o
?????文件??????11520??2013-01-09?19:02??OLED附送資料\OLED-K60\Debug\Obj\memtest.o
?????文件??????10000??2013-01-13?23:14??OLED附送資料\OLED-K60\Debug\Obj\PIT.o
............此處省略974個文件信息
- 上一篇:Windows中realtek-VLAN驅動
- 下一篇:單相正弦波逆變電源
評論
共有 條評論