#include "common.h"
#include <module_gpio.h>
int main (void)
{
// char ch;
// uint32_t result=0;
// int i=0;
SIM_SCGC5 |= SIM_SCGC5_PORTA_MASK;
EnableInterrupts;
while(1)
{
if(flag0.collect_finish==1)
uart_send((void *)(&uartRT_pack),sizeof(uartRT_pack));
}
}
void uart_send(void *p,uint32_t num)
{
uint8_t *q;
uint32_t i;
q=(uint8_t *)malloc(num);
strncpy((void *)q,p,num);
for(i=0;i<num;i++)
out_char(q);
free(q);
}
虽然发现这里malloc使用的有点多余,但是想知道为什么使用malloc会产生警告~
使用的开发环境是KEIL 5.16 谢谢啦
工程文件中有 alloc.c malloc在alloc.c中定义。如下所示:贴了部分代码,问题主要在
extern uint32_t HEAP$$Base;extern uint32_t HEAP$$Limit;两句中
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");
#elif defined(KEIL)
extern uint32_t HEAP$$Base;
extern uint32_t HEAP$$Limit;
uint32_t __HEAP_START = (uint32_t)&HEAP$$Base;
uint32_t __HEAP_END = (uint32_t)&HEAP$$Limit;
#endif
ALLOC_HDR *p, *prevp;
|