LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Attempt to realloc pointer to memory not allocated by malloc() or calloc()

hello all,
sometimes i get this error :
and i don't know how to solve it !!
and my program doesn't work when i switch to debug run ,
CaptureError.PNG

i even try to make a small project (just for getting the same error to know what's the responsible of this)
but i can't do it ,
can someone help me to solve this error ,

or how i can make a little program to get this error.

0 Kudos
Message 1 of 8
(5,218 Views)

In C memory allocation is left entirely as an exercise to the reader... Well, the standard library (ansi_c.h in CVI) provides malloc/calloc/realloc/free, but there are many other libraries (open source or not) that provides _other_ functions with the same names that work in different ways (usually to track allocations or debug memory issues) or with similar names.

 

In your case it could simply be trying to use realloc on a block of memory not allocated by malloc/calloc/realloc. For instance a static array or an array on the stack. How is you block defined ?

0 Kudos
Message 2 of 8
(5,181 Views)

my bloc is define like that :

Ptr->ptrC[i]->ptrA[j]->Left->ptrset->value

Ptr, ptrC[i] , ptrA[j] , Left and ptrset are struct

and value is long

but i dont use realloc in my program

0 Kudos
Message 3 of 8
(5,167 Views)

I don't see any definitions in the lines you pasted. Are you using external libraries/dll that maybe use realloc ?

0 Kudos
Message 4 of 8
(5,130 Views)

This popup panel is from CVI? In my case it looks very different...

0 Kudos
Message 5 of 8
(5,113 Views)

sorry for being late ,

the definition like is : ( Ptr have type tM)

Ptr->ptrC[i]->ptrA[j]->Left->ptrset->value

--------------
typedef struct t_M
{
int iI,
iM;
int iThreadID;
int iCodeDefaut;
char sCodeDefaut[512];
int iTestTime;
char strOrdreFab[100];
char strCodeProduit[100];
char strIndiceProduit[100];
struct t_Ca *ptrC[2]; //High & Low
struct t_Metro *ptrMet[12]; //Nombre des points
}tM;

struct t_Ca
{
int value;
struct t_Adj *ptrA[3]; //3 phase
};

struct t_Metro
{
struct t_Acc *ptrAccuracy[3]; //3 phase
};

struct t_Acc
{
struct t_Error *Left;
struct t_Error *Right;
};
struct t_Adj
{
struct t_Param *Left;
struct t_Param *Right;
};

struct t_Param {

struct t_Ca* ptrset;
struct t_Ca* ptrget;
};


struct t_Error {
double dErr1;
double dErr2;
double dErr3;
double dErr4;
};

 

/**/

for example how can i get the same error in a small project ?

another question if you dont mind where you read ( you know ) all this about the standard library (ansi_c.h in CVI)?

and about malloc and calloc ?

thanks

 

 

 

0 Kudos
Message 6 of 8
(4,921 Views)

sorry for being late,

yes this popup panel is from CVI and i use CVI 2012

 

0 Kudos
Message 7 of 8
(4,916 Views)

Whoa, that is some indirection nightmare, gives me a headache trying to follow the pointers ! And I agree that this doesn't look like a CVI popup, unless the OS was strangely themed.

0 Kudos
Message 8 of 8
(4,862 Views)