TR_datastructures 0.1.0
A generic C data structures library
Loading...
Searching...
No Matches
Typedefs | Enumerations
tr_result.h File Reference

Library wide error code definitions for the tr_datastructures library. More...

Go to the source code of this file.

Typedefs

typedef enum tr_result tr_result_t
 Library wide error code returned by all API functions.
 

Enumerations

enum  tr_result {
  TR_OK = 0 , TR_ERR_NULL = 1 , TR_ERR_ALLOC = 2 , TR_ERR_EMPTY = 3 ,
  TR_ERR_FULL = 4 , TR_ERR_INVALID = 5 , TR_ERR_NOT_FOUND = 6 , TR_ERR_DUPLICATE = 7 ,
  TR_ERR_OUT_OF_RANGE = 8
}
 Library wide error code returned by all API functions. More...
 

Detailed Description

Library wide error code definitions for the tr_datastructures library.

Typedef Documentation

◆ tr_result_t

typedef enum tr_result tr_result_t

Library wide error code returned by all API functions.

Every public API function returns a value of this type. TR_OK indicates success. Any other value indicates a specific failure condition that the caller should handle.

Example usage:

struct stack *p_stack = NULL;
res = tr_stack_create(sizeof(int), 10, TR_STACK_ARRAY_DYNAMIC, &p_stack);
if (TR_OK != res)
{
// handle error
}
#define NULL
Null pointer constant.
Definition tr_types.h:199
@ TR_OK
Definition tr_result.h:71
enum tr_result tr_result_t
Library wide error code returned by all API functions.
tr_result_t tr_stack_create(size_t size_of_datatype, size_t elements_to_allocate, tr_stack_type_t stack_type, struct stack **id_of_stack)
Allocates and initialises a new stack instance.
@ TR_STACK_ARRAY_DYNAMIC
Definition tr_stack.h:127

Enumeration Type Documentation

◆ tr_result

enum tr_result

Library wide error code returned by all API functions.

Every public API function returns a value of this type. TR_OK indicates success. Any other value indicates a specific failure condition that the caller should handle.

Example usage:

struct stack *p_stack = NULL;
res = tr_stack_create(sizeof(int), 10, TR_STACK_ARRAY_DYNAMIC, &p_stack);
if (TR_OK != res)
{
// handle error
}
Enumerator
TR_OK 

Operation completed successfully

TR_ERR_NULL 

NULL pointer passed where a valid pointer expected

TR_ERR_ALLOC 

Memory allocation failed

TR_ERR_EMPTY 

Operation failed because structure is empty

TR_ERR_FULL 

Operation failed because structure is full

TR_ERR_INVALID 

Invalid argument (e.g. size of 0)

TR_ERR_NOT_FOUND 

Element not found in the structure

TR_ERR_DUPLICATE 

Duplicate element detected

TR_ERR_OUT_OF_RANGE 

Index or position is out of valid range