[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Problems with the Free function.



Cory,

 

I noticed you used a local DataInterChange variable which is fine to do, but did you use any local variables for any of its members?  If so you would probably get a Segmentation Fault at the time they are freed.  If you have further questions, please send your entire source code for your test driver.

 

Thanks,

Tom 

 


From: owner-imc-snacc@xxxxxxxxxxxx [mailto:owner-imc-snacc@xxxxxxxxxxxx] On Behalf Of Cory Schanzenbach
Sent: Friday, January 27, 2006 9:11 AM
To: imc-snacc@xxxxxxx
Subject: Problems with the Free function.

 

Hello,

 

I am having trouble with the ESNACC defined function that will free the entire structure (DataInterChange) used to encode Tap3 data. Here is the definition of DataInterChange.

 

typedef struct DataInterChange /* CHOICE */
{
    enum DataInterChangeChoiceId
    {
        DATAINTERCHANGE_TRANSFERBATCH,
        DATAINTERCHANGE_NOTIFICATION
    } choiceId;
    union DataInterChangeChoiceUnion
    {
        struct TransferBatch* transferBatch; /* TransferBatch */
        struct Notification* notification; /* Notification */
    } a;
} DataInterChange
;

 

I have a variable defined in my program as follows: DataInterChange sData;

 

Here is the ESNACC defined free function:

void FreeDataInterChange(DataInterChange *v); 

 

void FreeDataInterChange(DataInterChange *v)
{

 

        if(v == NULL)
                return;
        switch(v->choiceId)
    {
           case DATAINTERCHANGE_TRANSFERBATCH:
        FreeTransferBatch(v->a.transferBatch);
        Asn1Free ((v->a.transferBatch));

 

        break;

 

           case DATAINTERCHANGE_NOTIFICATION:
        FreeNotification(v->a.notification);
        Asn1Free ((v->a.notification));

 

        break;

 

        }
}  /* FreeDataInterChange */

 

Here is the call to that function that I use: FreeDataInterChange(&sData);

 

I guess I am a little confused as to why I get a "Segmentation Fault". I am able to use the ESNACC defined print function which has the exact same parameters as the free. That works fine, but the free does not.

 

Has anyone ran into this or does anyone have any suggestions?

 

Thanks,

Cory

Cory Schanzenbach___________________
Senior Software Specialist
National Information Solutions Cooperative
3201 Nygren Drive
Mandan, ND 58554
+ Email: cory.schanzenbach@xxxxxxxxx
( Phone: 866.WWW.NISC (866.999.6472)

 

GIF image