Page 1 of 1

calling BCI_ReleaseObject(const char*)

Posted: 10 May 2011, 05:13
by OKI
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

Re: calling BCI_ReleaseObject(const char*)

Posted: 10 May 2011, 08:21
by mellinger
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

Re: calling BCI_ReleaseObject(const char*)

Posted: 11 May 2011, 04:28
by OKI
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

Re: calling BCI_ReleaseObject(const char*)

Posted: 11 May 2011, 10:30
by mellinger
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