Object¶
-
typedef struct cardano_object_t cardano_object_t¶
Base object type.
All objects in the library are derived from this type.
-
void cardano_object_unref(cardano_object_t **object)¶
Decrements the object’s reference count.
If the reference count reaches zero, the object memory is deallocated.
- Parameters:¶
- cardano_object_t **object¶
[in] Pointer to the object whose reference count is to be decremented.
-
void cardano_object_ref(cardano_object_t *object)¶
Increments the object’s reference count.
Ensures that the object remains allocated until the last reference is released.
- Parameters:¶
- cardano_object_t *object¶
[in] object whose reference count is to be incremented.
-
size_t cardano_object_refcount(const cardano_object_t *object)¶
Retrieves the object’s current reference count.
Warning
Does not account for transitive references.
- Parameters:¶
- const cardano_object_t *object¶
[in] Target object.
- Returns:¶
Current reference count of the object.
-
void cardano_object_set_last_error(cardano_object_t *object, const char *message)¶
Sets the last error message for a given object.
This function records an error message in the object’s last_error buffer, overwriting any previous message. The message is truncated if it exceeds the buffer size. This function is typically used to store descriptive error information that can be retrieved later with cardano_object_get_last_error.
Note
The error message is limited to 1023 characters due to the fixed size of the last_error buffer (1024 characters), including the null terminator. Messages longer than this limit will be truncated.
- Parameters:¶
- cardano_object_t *object¶
[inout] A pointer to the cardano_object_t instance whose last error message is to be set. If the object is NULL, the function has no effect.
- const char *message¶
[in] A null-terminated string containing the error message to be recorded. If the message is NULL, the object’s last_error will be set to an empty string, indicating no error.
-
const char *cardano_object_get_last_error(const cardano_object_t *object)¶
Retrieves the last error message recorded for a specific object.
This function returns a pointer to the null-terminated string containing the last error message set by cardano_object_set_last_error for the given object. If no error message has been set, or if the last_error buffer was explicitly cleared, an empty string is returned, indicating no error.
Note
The returned string points to internal storage within the object and must not be modified by the caller. The string remains valid until the next call to cardano_object_set_last_error for the same object, or until the object is deallocated.
- Parameters:¶
- const cardano_object_t *object¶
[inout] A pointer to the cardano_object_t instance whose last error message is to be retrieved. If the object is
NULL, the function returns a generic error message indicating the null object.
- Returns:¶
A pointer to a null-terminated string containing the last error message for the specified object. If the object is
NULL, “Object is NULL.” is returned to indicate the error.