Library Functions.
More...
Library Functions.
| #define TM_STRING_GetCount |
( |
|
str | ) |
((str)->Count) |
Gets number of strings in a string array.
- Parameters
-
- Return values
-
| Number | of strings in array |
- Note
- Defined as macro for faster execution
| uint16_t TM_STRING_AddString |
( |
TM_STRING_t * |
String, |
|
|
char * |
str |
|
) |
| |
Adds new string to main string structure.
- Note
- Function uses malloc() to allocate memory for string where it will copy it. Memory size for allocation is string length + 1
- Parameters
-
| *String | Pointer to TM_STRING_t structure |
| *str | Pointer to string to be added to string |
- Return values
-
| String | position in strings array |
Creates and allocated string structure and memory for pointers for desired number of strings.
- Note
- Function uses malloc() to allocate main structure and all pointers depending on count variable, so make sure that you have enough HEAP memory reserved
- Parameters
-
| count | Number of strings you will use. Set to 1, if you don't know how many of them will be used. It's recommended that you select the number which is greater or equal to count of all strings |
- Return values
-
| Pointer | to allocated TM_STRING_t structure or NULL of malloc() fails |
Deletes string from strings array.
- Parameters
-
| *String | Pointer to TM_STRING_t structure |
| pos | Position number in string array which string will be deleted. This number can be a value between 0 and number of strings - 1 |
- Return values
-
Free main structure and pointer to all pointers.
- Note
- This is not meant for public use unless you know what you are doing. It will deallocate structure, but all strings will stay untouched in heap memory! Use TM_STRING_FreeAll() instead.
- Parameters
-
Free all. It will free all strings, all pointers to strings and also main string structure.
- Note
- Use TM_STRING_DeleteString() to delete only one string if needed
- Parameters
-
- Return values
-
| char* TM_STRING_GetString |
( |
TM_STRING_t * |
String, |
|
|
uint16_t |
pos |
|
) |
| |
Gets pointer to string at desired position.
- Parameters
-
| *String | Pointer to TM_STRING_t structure |
| pos | Position number in string array which string pointer will be returned. This number can be a value between 0 and number of strings - 1 |
- Return values
-
| Pointer | to string at desired position in string array |
Replaces already added string with new string.
- Note
- If new string is larger than string before, new memory is allocated and old is free, but if new string length is smaller than old, only new string is copied to already allocateed memory
- Parameters
-
| *String | Pointer to TM_STRING_t structure |
| pos | Position in array where to replace string |
| *str | Pointer to new string which will be applied to memory |
- Return values
-