Skip to content

Commit be25fa3

Browse files
authored
chore: update client-side docs to indicate ownership of objects (#221)
This commit updates `LDClientSDK_New` with docs indicating that ownership of config & context are transferred. Other APIs are updated with more explicit wording as well.
1 parent cd00d76 commit be25fa3

File tree

2 files changed

+22
-10
lines changed
  • libs/client-sdk/include/launchdarkly/client_side/bindings/c

2 files changed

+22
-10
lines changed

libs/client-sdk/include/launchdarkly/client_side/bindings/c/config/config.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ extern "C" { // only need to export C interface if
1414
typedef struct _LDClientConfig* LDClientConfig;
1515

1616
/**
17-
* Free the configuration. Configurations passed into an LDClient do not need to
18-
* be freed.
17+
* Frees an unused configuration. Configurations passed into an LDClient must
18+
* not be be freed.
19+
*
1920
* @param config Config to free.
2021
*/
2122
LD_EXPORT(void) LDClientConfig_Free(LDClientConfig config);

libs/client-sdk/include/launchdarkly/client_side/bindings/c/sdk.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ typedef struct _LDClientSDK* LDClientSDK;
3232
/**
3333
* Constructs a new client-side LaunchDarkly SDK from a configuration and
3434
* context.
35-
* @param config The configuration. Must not be NULL.
36-
* @param context The initial context. Must not be NULL.
37-
* @return New SDK instance.
35+
* @param config The configuration. Ownership is transferred. Do not free or
36+
* access the LDClientConfig in any way after this call; behavior is undefined.
37+
* Must not be NULL.
38+
* @param context The initial context. Ownership is transferred. Do not free or
39+
* access the LDContext in any way after this call; behavior is undefined. Must
40+
* not be NULL.
41+
* @return New SDK instance. Must be freed with LDClientSDK_Free when no longer
42+
* needed.
3843
*/
3944
LD_EXPORT(LDClientSDK)
4045
LDClientSDK_New(LDClientConfig config, LDContext context);
@@ -135,7 +140,9 @@ LD_EXPORT(void) LDClientSDK_TrackEvent(LDClientSDK sdk, char const* event_name);
135140
* feature in numeric custom metrics, and will also be returned as part of the
136141
* custom event for Data Export.
137142
* @param data A JSON value containing additional data associated with the
138-
* event. Must not be NULL.
143+
* event. Ownership is transferred. Do not free or
144+
* access the LDValue in any way after this call; behavior is undefined. Must
145+
* not be NULL.
139146
*/
140147
LD_EXPORT(void)
141148
LDClientSDK_TrackMetric(LDClientSDK sdk,
@@ -149,7 +156,9 @@ LDClientSDK_TrackMetric(LDClientSDK sdk,
149156
* @param sdk SDK. Must not be NULL.
150157
* @param event_name Must not be NULL.
151158
* @param data A JSON value containing additional data associated with the
152-
* event. Must not be NULL.
159+
* event. Do not free or
160+
* access the LDValue in any way after this call; behavior is undefined. Must
161+
* not be NULL.
153162
*/
154163
LD_EXPORT(void)
155164
LDClientSDK_TrackData(LDClientSDK sdk, char const* event_name, LDValue data);
@@ -354,7 +363,8 @@ LDClientSDK_DoubleVariationDetail(LDClientSDK sdk,
354363
* Returns the JSON value of a feature flag for a given flag key.
355364
* @param sdk SDK. Must not be NULL.
356365
* @param flag_key The unique key for the feature flag. Must not be NULL.
357-
* @param default_value The default value of the flag. The value is copied.
366+
* @param default_value The default value of the flag. Ownership is retained by
367+
* the caller; a copy is made internally. Must not be NULL.
358368
* @return The variation for the current context, or a copy of default_value if
359369
* the flag is disabled in the LaunchDarkly control panel. The returned value
360370
* must be freed using LDValue_Free.
@@ -369,7 +379,8 @@ LDClientSDK_JsonVariation(LDClientSDK sdk,
369379
* that also describes the way the value was determined.
370380
* @param sdk SDK. Must not be NULL.
371381
* @param flag_key The unique key for the feature flag. Must not be NULL.
372-
* @param default_value The default value of the flag. The value is copied.
382+
* @param default_value The default value of the flag. Ownership is retained by
383+
* the caller; a copy is made internally. Must not be NULL.
373384
* @param detail Out parameter to store the details. May pass LD_DISCARD_DETAILS
374385
* or NULL to discard the details. The details object must be freed with
375386
* LDEvalDetail_Free.
@@ -402,7 +413,7 @@ LDClientSDK_JsonVariationDetail(LDClientSDK sdk,
402413
* }
403414
* @endcode
404415
* @param sdk SDK. Must not be NULL.
405-
* @return Value of type Object.
416+
* @return Value of type Object. Must be freed with LDValue_Free.
406417
*/
407418
LD_EXPORT(LDValue)
408419
LDClientSDK_AllFlags(LDClientSDK sdk);

0 commit comments

Comments
 (0)