本程序经历了华南赛区决赛的检验,通过此程序助我们顺利冲进国赛。
代码片段和文件信息
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-01 20:51 决赛程序
文件 171 2014-02-22 11:45 决赛程序TEST1.eww
目录 0 2014-04-01 20:51 决赛程序uild
目录 0 2014-11-05 20:15 决赛程序uildTEST1
目录 0 2014-04-01 20:51 决赛程序uildTEST1Debug
目录 0 2014-07-28 15:34 决赛程序uildTEST1DebugExe
文件 60551 2014-07-28 15:34 决赛程序uildTEST1DebugExefire_gpio_demo.hex
文件 305708 2014-07-28 15:34 决赛程序uildTEST1DebugExefire_gpio_demo.out
文件 21559 2014-07-28 15:38 决赛程序uildTEST1DebugExefire_gpio_demo.sim
目录 0 2014-07-28 15:34 决赛程序uildTEST1DebugList
文件 36111 2014-07-28 15:34 决赛程序uildTEST1DebugListfire_gpio_demo.map
目录 0 2014-11-05 20:15 决赛程序uildTEST1DebugObj
文件 21864 2014-07-28 15:34 决赛程序uildTEST1DebugObjFTM.o
文件 43508 2014-07-28 15:34 决赛程序uildTEST1DebugObjLCDinit.o
文件 14348 2014-07-28 15:34 决赛程序uildTEST1DebugObjLED.o
文件 9812 2014-07-28 15:34 决赛程序uildTEST1DebugObjPIT.o
文件 2361 2014-08-17 13:34 决赛程序uildTEST1DebugObjTEST1.pbd
文件 26584 2014-07-28 15:34 决赛程序uildTEST1DebugObjadc.o
文件 11840 2014-07-28 15:34 决赛程序uildTEST1DebugObjalloc.o
文件 17044 2014-07-28 15:34 决赛程序uildTEST1DebugObjarm_cm4.o
文件 8656 2014-07-28 15:34 决赛程序uildTEST1DebugObjassert.o
文件 54868 2014-07-28 15:34 决赛程序uildTEST1DebugObjchu_li.o
文件 1760 2014-07-28 15:34 决赛程序uildTEST1DebugObjcrt0.o
文件 27876 2014-07-28 15:34 决赛程序uildTEST1DebugObjdata.o
文件 9312 2014-07-28 15:34 决赛程序uildTEST1DebugObjdelay.o
文件 22188 2014-07-28 15:34 决赛程序uildTEST1DebugObjdma.o
文件 8552 2014-07-28 15:34 决赛程序uildTEST1DebugObjexti.o
文件 18180 2014-07-28 15:34 决赛程序uildTEST1DebugObjgpio.o
文件 10440 2014-07-28 15:34 决赛程序uildTEST1DebugObjio.o
文件 19212 2014-07-28 15:34 决赛程序uildTEST1DebugObjisr.o
文件 9704 2014-07-28 15:34 决赛程序uildTEST1DebugObjkey.o
............此处省略249个文件信息
/*
* 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 < p->s.ptr)) ; p = p->s.ptr)
{
if ((p >= p->s.ptr) && ((bp > p) || (bp < p->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;
}
}
/**************************************************
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-01 20:51 决赛程序
文件 171 2014-02-22 11:45 决赛程序TEST1.eww
目录 0 2014-04-01 20:51 决赛程序uild
目录 0 2014-11-05 20:15 决赛程序uildTEST1
目录 0 2014-04-01 20:51 决赛程序uildTEST1Debug
目录 0 2014-07-28 15:34 决赛程序uildTEST1DebugExe
文件 60551 2014-07-28 15:34 决赛程序uildTEST1DebugExefire_gpio_demo.hex
文件 305708 2014-07-28 15:34 决赛程序uildTEST1DebugExefire_gpio_demo.out
文件 21559 2014-07-28 15:38 决赛程序uildTEST1DebugExefire_gpio_demo.sim
目录 0 2014-07-28 15:34 决赛程序uildTEST1DebugList
文件 36111 2014-07-28 15:34 决赛程序uildTEST1DebugListfire_gpio_demo.map
目录 0 2014-11-05 20:15 决赛程序uildTEST1DebugObj
文件 21864 2014-07-28 15:34 决赛程序uildTEST1DebugObjFTM.o
文件 43508 2014-07-28 15:34 决赛程序uildTEST1DebugObjLCDinit.o
文件 14348 2014-07-28 15:34 决赛程序uildTEST1DebugObjLED.o
文件 9812 2014-07-28 15:34 决赛程序uildTEST1DebugObjPIT.o
文件 2361 2014-08-17 13:34 决赛程序uildTEST1DebugObjTEST1.pbd
文件 26584 2014-07-28 15:34 决赛程序uildTEST1DebugObjadc.o
文件 11840 2014-07-28 15:34 决赛程序uildTEST1DebugObjalloc.o
文件 17044 2014-07-28 15:34 决赛程序uildTEST1DebugObjarm_cm4.o
文件 8656 2014-07-28 15:34 决赛程序uildTEST1DebugObjassert.o
文件 54868 2014-07-28 15:34 决赛程序uildTEST1DebugObjchu_li.o
文件 1760 2014-07-28 15:34 决赛程序uildTEST1DebugObjcrt0.o
文件 27876 2014-07-28 15:34 决赛程序uildTEST1DebugObjdata.o
文件 9312 2014-07-28 15:34 决赛程序uildTEST1DebugObjdelay.o
文件 22188 2014-07-28 15:34 决赛程序uildTEST1DebugObjdma.o
文件 8552 2014-07-28 15:34 决赛程序uildTEST1DebugObjexti.o
文件 18180 2014-07-28 15:34 决赛程序uildTEST1DebugObjgpio.o
文件 10440 2014-07-28 15:34 决赛程序uildTEST1DebugObjio.o
文件 19212 2014-07-28 15:34 决赛程序uildTEST1DebugObjisr.o
文件 9704 2014-07-28 15:34 决赛程序uildTEST1DebugObjkey.o
............此处省略249个文件信息
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。
评论列表(条)