Closed xiaodingding closed 5 years ago
经实际使用于STM32F107中,cJSON_Print 返回的指针地址为NULL,请问这个是什么原因?
代码如下: static Student orignal_student_obj = { .id = 24, .weight = 71.2, .score = {1, 2, 3, 4, 5, 6, 7, 8}, .name = "armink", .hometown.name = "China", };
cJSON *json_send = struct_to_json(&orignal_student_obj);
//cJSON *json_send = struct_to_json(&send_struct); ptr = cJSON_Print(json_send);
标准库的 动态内存管理 api 实现了吗?
需要用到 malloc/free 的
使用的是默认的malloc/free
使用的编辑器是Keil
那应该是内存不足,或者你的动态内存初始化就没有做好。
自己先写个简单的 malloc/free 验证下吧。
I have solved this problem. Thank you
经实际使用于STM32F107中,cJSON_Print 返回的指针地址为NULL,请问这个是什么原因?
代码如下: static Student orignal_student_obj = { .id = 24, .weight = 71.2, .score = {1, 2, 3, 4, 5, 6, 7, 8}, .name = "armink", .hometown.name = "China", };
cJSON *json_send = struct_to_json(&orignal_student_obj);