chore: reverting callback changes

This commit is contained in:
Prem Chaitanya Prathi 2024-02-22 16:47:07 +05:30
parent 34fd921b89
commit 97b7ef1156
No known key found for this signature in database
2 changed files with 8 additions and 11 deletions

View File

@ -42,23 +42,19 @@ void* negentropy_new(void* storage, uint64_t frameSizeLimit){
return ne;
}
void negentropy_initiate(void* negentropy, void (*callback)(const char* buf, size_t len)){
const char* negentropy_initiate(void* negentropy){
Negentropy<negentropy::storage::BTreeMem>* ngn_inst;
ngn_inst = reinterpret_cast<Negentropy<negentropy::storage::BTreeMem>*>(negentropy);
std::string output;
std::string* output = new std::string();
try {
output = ngn_inst->initiate();
std::cout << "output of initiate is, len:" << output.size() << std::hex << output << std::endl;
*output = ngn_inst->initiate();
std::cout << "output of initiate is, len:" << output->size() << std::hex << *output << std::endl;
} catch(negentropy::err e){
//TODO:Find a way to return this error
callback(NULL,0);
return ;
return NULL;
}
callback(output.c_str(), output.size());
//TODO: Avoid copy and use a callback
//memcpy(buf, output, output.size())
return ;
return output->c_str();
}
void negentropy_setinitiator(void* negentropy){

View File

@ -1,3 +1,4 @@
#ifndef _NEGENTROPY_WRAPPER_H
#define _NEGENTROPY_WRAPPER_H
@ -19,7 +20,7 @@ EXTERNC void* storage_new(const char* db_path, const char* name);
EXTERNC void* negentropy_new(void* storage, uint64_t frameSizeLimit);
EXTERNC void negentropy_initiate(void* negentropy, void *(const char* buf, size_t len));
EXTERNC const char* negentropy_initiate(void* negentropy);
EXTERNC void negentropy_setinitiator(void* negentropy);