Skip to content

Commit

Permalink
C++ API: (lec.h/cpp) added clec_deep_copy() function
Browse files Browse the repository at this point in the history
  • Loading branch information
alixdamman committed Oct 25, 2023
1 parent 41676e3 commit 3621f65
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
20 changes: 20 additions & 0 deletions cpp_api/lec/lec.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
#include "lec.h"


CLEC* clec_deep_copy(const CLEC* other)
{
// NOTE : see end of function L_cc2() from l_cc2.c to calculate tot_lg (= len)
CLEC* copy = (CLEC*) SW_nalloc(other->tot_lg);

copy->tot_lg = other->tot_lg,
copy->exec_lg = other->exec_lg;
copy->nb_names = other->nb_names;
copy->dupendo = other->dupendo;
copy->pad = '\0';
for(int i = 0; i < other->nb_names; i++)
{
strncpy(copy->lnames[i].name, other->lnames[i].name, sizeof(ONAME) / sizeof(char));
memset(copy->lnames[i].pad, '\0', sizeof(LNAME::pad) / sizeof(char));
copy->lnames[i].pos = other->lnames[i].pos;
}

return copy;
}

/**
* Compile and link the LEC expression with the current Scalars and Variables workspaces.
*
Expand Down
9 changes: 9 additions & 0 deletions cpp_api/lec/lec.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
#include "time/period.h"
#include "KDB/kdb_variables.h"

/**
* @brief
*
* @param other
* @return CLEC*
*
* @note
*/
CLEC* clec_deep_copy(const CLEC* other);

/**
* Evaluate the LEC expression for a specific period t.
Expand Down

0 comments on commit 3621f65

Please sign in to comment.