FreeTDS API: Dynamic string functions

FreeTDS API

- Main Page
- Related Pages
- Modules
- Classes
- Files

All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Macros | Functions
Dynamic string functions
LibTDS API

Handle dynamic string. More...

Collaboration diagram for Dynamic string functions:

## Macros
#define | tds_dstr_buf(s) ((*(s))->dstr_s)
#define | tds_dstr_cstr(s) ((const char* ) tds_dstr_buf(s))
#define | tds_dstr_empty(s) tds_dstr_free(s)
| Make a string empty.
#define | tds_dstr_init(s) do { *(s) = (struct tds_dstr*) &tds_str_empty; } while(0)
| init a string with empty
#define | tds_dstr_isempty(s) ((*(s))->dstr_size == 0)
| test if string is empty
#define | tds_dstr_len(s) ((*(s))->dstr_size)
#define | TDS_WUR

## Functions
DSTR * | tds_dstr_alloc (DSTR *s, size_t length)
| allocate space for length char More...
DSTR * | tds_dstr_copy (DSTR *s, const char *src)
| copy a string from another More...
DSTR * | tds_dstr_copyn (DSTR *s, const char *src, size_t length)
| Set string to a given buffer of characters. More...
DSTR * | tds_dstr_dup (DSTR *s, const DSTR *src)
void | tds_dstr_free (DSTR *s)
| free string
DSTR * | tds_dstr_set (DSTR *s, char *src)
| set a string from another buffer. More...
DSTR * | tds_dstr_setlen (DSTR *s, size_t length)
| limit length of string, MUST be <= current length More...
void | tds_dstr_zero (DSTR *s)
| clear all string filling with zeroes (mainly for security reason)

## Detailed Description

Handle dynamic string.

In this string are always valid (you don't have NULL pointer, only empty string)

## Function Documentation

DSTR * tds_dstr_alloc | ( | DSTR * | s,
|  | size_t | length
| ) |  |

allocate space for length char

Parameters

  s | dynamic string
  length | new length

Returns
  string allocated or NULL on memory error

Here is the caller graph for this function:

DSTR * tds_dstr_copy | ( | DSTR * | s,
|  | const char * | src
| ) |  |

copy a string from another

Parameters

  s | dynamic string
  src | source buffer

Returns
  string copied or NULL on memory error

Here is the call graph for this function:

Here is the caller graph for this function:

DSTR * tds_dstr_copyn | ( | DSTR * | s,
|  | const char * | src,
|  | size_t | length
| ) |  |

Set string to a given buffer of characters.

Parameters

  s | dynamic string
  src | source buffer
  length | length of source buffer

Returns
  string copied or NULL on memory error

Here is the caller graph for this function:

DSTR * tds_dstr_set | ( | DSTR * | s,
|  | char * | src
| ) |  |

set a string from another buffer.

The string will use the supplied buffer (it not copy the string), so it should be a pointer returned by malloc.

Parameters

  s | dynamic string
  src | source buffer

Returns
  string copied or NULL on memory error

Here is the call graph for this function:

DSTR * tds_dstr_setlen | ( | DSTR * | s,
|  | size_t | length
| ) |  |

limit length of string, MUST be <= current length

Parameters

  s | dynamic string
  length | new length

Here is the caller graph for this function: