有人可以帮我找到我的内存泄漏吗?我使用 valgrind 检查泄漏,但找不到它报告的泄漏。谢谢!
bigint* bi_create(const char* charint)
{
int length = 0;
const char* temp;
int flag = 0;
temp = charint;
while(*charint != '\0')
{
length++;
charint++;
}
char chartoint[length];
charint = temp;
//printf("LENGTH = %d \n", length);
bigint* bi = malloc(sizeof(bigint));
bi->length = length;
int counter = 0;
bi->initialzero = 0;
while(*charint != '\0')
{
if(*charint == '0' && flag != 1)
{
(bi->initialzero)++;
}else
{
flag = 1;
}
chartoint[counter] = *charint;
// printf("CHARTOINT = %c \n", chartoint[counter]);
charint++;
counter++;
}
bi->data = atoi(chartoint);
printf("DATA = %d \n", bi->data);
// printf("INITIAL ZERO = %d \n", bi->initialzero);
return bi;
}