array error

hrk l8atnight at gmail.com
Sun Jul 20 01:18:18 PDT 2008


Hi,

I have a class STATUS, in which i do have an dynamic array

class STATUS {
private:
int mVector[];
public:
int* StatusHandle() {
    return cast(int*) this.mVector.ptr;
  }
bool Errors() {
    ...
 }
int SqlCode() {
...
}
  int EngineCode() {
...
}
void Reset() {
  mVector[] = 0;
}
this(int asize) {
   mVector.length = asize;
    mVector[] = 0;
}
  string ErrorMessage() {
...
}
}

The method  StatusHandle() returns a pointer that is the input for a function in a “C” DLL. 

The class is newed, along with other classes of this kind (STATUS), in an other classes method:

bool Connect(string dbname, string username, string password, string RoleName = "", string CharSet = "") {
      auto status = new STATUS(200);
.........
......... 
cresult = isc_database_info(status.StatusHandle(), &db, 3, cast(char*) items.ptr, 200, result.ResultHandle());
.........
.........
.........
}

The class (STATUS) instances will function a couple of times, but than they crash unpredictably. 
Can anyone tell me what i am doing wrong? I need the memory of the array (mVector) to be contiguous and it’s content should only change through the manipulation of the pointer  StatusHandle() by the “C” DLL functions. I need sometimes several instances of the class STATUS that are created in some other class.
I am using 2.0 and phobos.



More information about the Digitalmars-d-learn mailing list