[Json -c] json_tokener_parse 로 만든 object가 free가 안됩니다.
      글쓴이: hwyuji0424 / 작성시간: 화, 2023/05/02 - 10:01오전    
  
  안녕하세요. 
c 언어로 json 파싱 프로그램을 만들고 있습니다.
아래와 같이 간단한 소스를 만들어 테스트 해봤는데, 메모리 프리가 안되는 현상이 발생했습니다.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
 
#include <json-c/json.h>
 
static char Data_buff[] = "[3,\"00009\",{\"Time\":\"2023-04-11T23:21:38Z\"}]";
 
void main(void)
{
	int i = 0 , j = 0;;
	json_object *oParsing = NULL;
	char Make_Data[1000];
	for(i = 0 ; i < 100 ; i++)
	{
		memcpy(Make_Data , Data_buff , sizeof(Data_buff));
		printf("%s  " , Make_Data);
		oParsing = json_tokener_parse(Make_Data);
		printf("[%x] \n" , oParsing);
		json_object_put(oParsing);
	}
}json_tokener_parse 때, array type으로 object가 리턴이 됩니다.
이 array type object 를 json_object_put으로 free를 하면, _ref_count 가 2라서 free가 안됩니다.
array type은 따로 free 하는 방법이 있는건가요????
감사합니다.
Forums: 


댓글 달기