improvements to the C wrapper and close a memory leak

This commit is contained in:
2023-02-21 21:31:04 -03:00
parent 0e9cc0f832
commit e665ff044f
4 changed files with 46 additions and 18 deletions

View File

@@ -1,25 +1,47 @@
#ifndef OBELISK_INCLUDE_OBELISK_PROGRAM_H
#define OBELISK_INCLUDE_OBELISK_PROGRAM_H
/**
* @brief Struct wrapper around Obelisk class.
*
*/
typedef struct CObelisk CObelisk;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Create an obelisk object.
*
* @return CObelisk* Returns an obelisk object.
*/
extern CObelisk* obelisk_open();
/**
* @brief Delete an obelisk object.
*
* @param[in] obelisk The obelisk object.
*/
extern void obelisk_close(CObelisk* obelisk);
/**
* @brief Get the obelisk version.
*
* @param[in] obelisk The obelisk object.
* @return const char* Returns a string containing the version. This must be
* freed by the caller.
*/
extern const char* obelisk_get_version();
extern char* obelisk_get_version(CObelisk* obelisk);
/**
* @brief Get the obelisk library so version.
*
* @param[in] obelisk The obelisk object.
* @return int Returns the so version.
*/
extern int obelisk_get_lib_version();
extern int obelisk_get_lib_version(CObelisk* obelisk);
#ifdef __cplusplus
};

View File

@@ -1,45 +0,0 @@
#ifndef OBELISK_INCLUDE_OBELISK_WRAPPER_H
#define OBELISK_INCLUDE_OBELISK_WRAPPER_H
typedef struct CObelisk CObelisk;
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Create a obelisk object.
*
* @return CObelisk* Returns the obelisk object.
*/
CObelisk *create_obelisk();
/**
* @brief Calls the obelisk method getVersion.
*
* @param[in] p_obelisk The obelisk object pointer.
* @return const char* Returns the version. Must be freed by caller.
*/
const char *call_obelisk_getVersion(CObelisk *p_obelisk);
/**
* @brief Calls the obelisk method getLibVersion.
*
* @param[in] p_obelisk The obelisk object pointer.
* @return int Returns the library so version.
*/
int call_obelisk_getLibVersion(CObelisk *p_obelisk);
/**
* @brief Delete a obelisk object.
*
* @param[in] p_obelisk The obelisk object pointer.
*/
void destroy_obelisk(CObelisk *p_obelisk);
#ifdef __cplusplus
};
#endif
#endif