calling BCI_ReleaseObject(const char*)

Forum for software developers to discuss BCI2000 software development
Locked
OKI
Posts: 18
Joined: 23 Jul 2010, 05:53

calling BCI_ReleaseObject(const char*)

Post by OKI » 10 May 2011, 05:13

Hello,

i'm currently working on a new Operator Module. For this i called the BCI Parameter Function const char * BCI_GetParameter( long index ). In the technical reference it also says, that the Object should be released again by calling int BCI_ReleaseObject( const char*) .
Now, when i try to call BCI_ReleaseObject(NULL) the returned value is Zero, so the operation was not sucessfull.

How do i have to call BCI_ReleaseObject()?

Thank you for attention,
Stefan

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Re: calling BCI_ReleaseObject(const char*)

Post by mellinger » 10 May 2011, 08:21

Hi Stefan,

you should call BCI_ReleaseObject() on the object returned by BCI_GetParameter(), as soon as you are done with it. E.g.,

Code: Select all

ParamList parameters;
...
const char* pParam = BCI_GetParameter( idx );
parameters.Add( pParam );
BCI_ReleaseObject( pParam );
...
Regards,
Juergen

OKI
Posts: 18
Joined: 23 Jul 2010, 05:53

Re: calling BCI_ReleaseObject(const char*)

Post by OKI » 11 May 2011, 04:28

Hi Mr. Mellinger,

this is the way i also tried it to do, but BCI_ReleaseObject() always returns a zero Value.

Here is some of my code:

Code: Select all

std::string
eGetParameter(std::string eParamName){
  int eIndex = 0;
  while(1){
    const char * eBuff = BCI_GetParameter(eIndex++);
    if(eBuff != NULL){
      std::string eStrBuf = eBuff;
      size_t eFound = eStrBuf.find(eParamName);
      if(eFound != std::string::npos){
        eStrBuf.erase(0,eFound+eParamName.length()+2);
        eFound = eStrBuf.find(" ");
        if(eFound != std::string::npos){
          eStrBuf.erase(eFound,eStrBuf.length()-eFound);
          return eStrBuf;
        }
      }
      int help = BCI_ReleaseObject(eBuff);
    }else
      break;
  }
  return "";
}
after calling BCI_ReleaseObject(eBuff) the integer help is set to 0, and the char * eBuff looses it's Values.

normally BCI_ReleaseObject should return 1 or?

Thanks for attention,
Stefan

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Re: calling BCI_ReleaseObject(const char*)

Post by mellinger » 11 May 2011, 10:30

Hi,

BCI_ReleaseObject() did not work as advertised--it always returned 0. It has been fixed now to check whether its argument pointer was actually allocated by the operator library. Only then or when the argument is NULL, the return value is 1.

Thank you for pointing me to this,
Mr. Mellinger

Locked

Who is online

Users browsing this forum: No registered users and 1 guest