| 232 | } |
| 233 | |
| 234 | int ReadAtCursor(Dbc* pcursor, CDataStream& ssKey, CDataStream& ssValue, unsigned int fFlags = DB_NEXT) |
| 235 | { |
| 236 | // Read at cursor |
| 237 | Dbt datKey; |
| 238 | if (fFlags == DB_SET || fFlags == DB_SET_RANGE || fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { |
| 239 | datKey.set_data(ssKey.data()); |
| 240 | datKey.set_size(ssKey.size()); |
| 241 | } |
| 242 | Dbt datValue; |
| 243 | if (fFlags == DB_GET_BOTH || fFlags == DB_GET_BOTH_RANGE) { |
| 244 | datValue.set_data(&ssValue[0]); |
| 245 | datValue.set_size(ssValue.size()); |
| 246 | } |
| 247 | datKey.set_flags(DB_DBT_MALLOC); |
| 248 | datValue.set_flags(DB_DBT_MALLOC); |
| 249 | int ret = pcursor->get(&datKey, &datValue, fFlags); |
| 250 | if (ret != 0) |
| 251 | return ret; |
| 252 | else if (datKey.get_data() == NULL || datValue.get_data() == NULL) |
| 253 | return 99999; |
| 254 | |
| 255 | // Convert to streams |
| 256 | ssKey.SetType(SER_DISK); |
| 257 | ssKey.clear(); |
| 258 | ssKey.write((char*)datKey.get_data(), datKey.get_size()); |
| 259 | ssValue.SetType(SER_DISK); |
| 260 | ssValue.clear(); |
| 261 | ssValue.write((char*)datValue.get_data(), datValue.get_size()); |
| 262 | |
| 263 | // Clear and free memory |
| 264 | memory_cleanse(datKey.get_data(), datKey.get_size()); |
| 265 | memory_cleanse(datValue.get_data(), datValue.get_size()); |
| 266 | free(datKey.get_data()); |
| 267 | free(datValue.get_data()); |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | public: |
| 272 | bool TxnBegin() |