DcmFileFormat as shared library function parameter

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
martinrame
Posts: 347
Joined: Mon, 2009-02-23, 19:57

DcmFileFormat as shared library function parameter

#1 Post by martinrame »

Hi, I'm passing a DcmFileFormat instance to a shared libary function, but aparently it is getting corrupted after calling getDataset() from inside the function.

Here's the caller:

Code: Select all

void* lhandle = dlopen("./libmylibrary.so", RTLD_NOW);

if (lhandle) {
  typedef void (* processDataset)(DcmFileFormat *);
  processDataset lprocessDset = (processDataset)dlsym(lhandle, "processDataset");
  if (!lprocessDset) {
     dlclose(lhandle);
     return;
  }
  lprocessDset(ff);
  dlclose(lhandle); // if I call dlclose(..) my app hangs
}
And here's my shared library function definition:

Code: Select all

extern "C" {
  void processDataset(DcmFileFormat *ff)
  {
    OFString lModality;
    DcmDataset * dataset = ff->getDataset(); // here ff is getting corrupted
    dataset->findAndGetOFString(DCM_Modality, lModality);
    dataset->putAndInsertOFStringArray(DCM_AccessionNumber, '123');
  }
}
Do you see anything wrong in my code?.

Thanks in advance.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest