Skip to content

Commit

Permalink
Add comments explaining how structs should be freed
Browse files Browse the repository at this point in the history
  • Loading branch information
erer1243 committed Jan 15, 2025
1 parent aa1a801 commit 18e938d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion common/c-api/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ typedef struct SWSSStrRefOpaque *SWSSStrRef;

// FFI version of swss::FieldValueTuple
// field should be freed with libc's free()
// value should be freed with SWSSString_free()
typedef struct {
const char *field;
SWSSString value;
} SWSSFieldValueTuple;

// FFI version of std::vector<swss::FieldValueTuple>
// data should be freed with SWSSFieldValueArray_free()
typedef struct {
uint64_t len;
SWSSFieldValueTuple *data;
Expand All @@ -37,13 +39,16 @@ typedef enum {
} SWSSKeyOperation;

// FFI version of swss::KeyOpFieldValuesTuple
// key should be freed with libc's free()
// fieldValues should be freed with SWSSFieldValueArray_free()
typedef struct {
const char *key;
SWSSKeyOperation operation;
SWSSFieldValueArray fieldValues;
} SWSSKeyOpFieldValues;

// FFI version of std::vector<swss::KeyOpFieldValueTuple>
// data should be freed with SWSSKeyOpFieldValuesArray_free()
typedef struct {
uint64_t len;
SWSSKeyOpFieldValues *data;
Expand All @@ -61,7 +66,8 @@ typedef enum {
} SWSSSelectResult;

// FFI version of std::vector<std::string>
// data strings should be freed with libc's free()
// strings in data should be freed with libc's free()
// data should be freed with SWSSStringArray_free()
typedef struct {
uint64_t len;
const char **data;
Expand Down

0 comments on commit 18e938d

Please sign in to comment.