微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > cc1310 ATTRIBUTE _realloc_r(struct _reent rptr, Void ptr, SizeT size) 这个函数有什么作用?ATTRIBUTE 是什么个意思?

cc1310 ATTRIBUTE _realloc_r(struct _reent rptr, Void ptr, SizeT size) 这个函数有什么作用?ATTRIBUTE 是什么个意思?

时间:12-23 整理:3721RD 点击:

/*
* ======== _realloc_r ========
*/
Void ATTRIBUTE *_realloc_r(struct _reent *rptr, Void *ptr, SizeT size)
{
return realloc(ptr, size);
}

#endif

uint32_t *newData = malloc (4);这样会报错

主要是分配内存,函数里主要是实现realloc(ptr, size):

realloc() changes the size of the memory block pointed to by ptr to size bytes. The contents will be unchanged to the minimum of the old and new sizes; newly allocated memory will be uninitialized. If ptr is NULL, the call is equivalent to malloc(size); if sizeis equal to zero, the call is equivalent to free(ptr). Unless ptr is NULL, it must have been returned by an earlier call to malloc(), calloc() or realloc(). If the area pointed to was moved, a free(ptr) is done.

其返回值是ATTRIBUTE,它是囊括多种数据类型,根据你传入的指针类型,返回一样的类型,不如指针是int *ptr,则分配内存后,返回int*类型

uint32_t *newData = malloc (4);这样会报错,试一下uint32_t *newData =(uint32_t *) malloc (4),就不会报错了。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top