FreeTDS API
Loading...
Searching...
No Matches
Macros | Functions | Variables
Memory allocation

Allocate or free resources. More...

Collaboration diagram for Memory allocation:

Macros

#define REQ(i, n)   |(((TDS_REQ_ ## n / 8) == i)?(1<<(TDS_REQ_ ## n & 7)):0)
 
#define REQB(i)   0 SUPPORTED_REQ_CAP(i)
 
#define RES(i, n)   |(((TDS_RES_ ## n / 8) == i)?(1<<(TDS_RES_ ## n & 7)):0)
 
#define RESB(i)   0 SUPPORTED_RES_CAP(i)
 
#define SQLS_ENTRY(number, state)   case number: p = state; break
 
#define SUPPORTED_REQ_CAP(i)
 
#define SUPPORTED_RES_CAP(i)    RES(i,CON_NOOOB) RES(i,PROTO_NOTEXT) RES(i,PROTO_NOBULK) RES(i,NOTDSDEBUG)
 

Functions

BCPCOLDATAtds_alloc_bcp_column_data (unsigned int column_size)
 
TDSBCPINFOtds_alloc_bcpinfo (void)
 
char * tds_alloc_client_sqlstate (int msgno)
 
static TDSCOLUMNtds_alloc_column (void)
 
static TDSCOMPUTEINFOtds_alloc_compute_result (TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
 Allocate memory for storing compute info return NULL on out of memory.
 
TDSCOMPUTEINFO ** tds_alloc_compute_results (TDSSOCKET *tds, TDS_USMALLINT num_cols, TDS_USMALLINT by_cols)
 
TDSRET tds_alloc_compute_row (TDSCOMPUTEINFO *res_info)
 
TDSCONTEXTtds_alloc_context (void *parent)
 
TDSCURSORtds_alloc_cursor (TDSSOCKET *tds, const char *name, TDS_INT namelen, const char *query, TDS_INT querylen)
 
TDSDYNAMICtds_alloc_dynamic (TDSCONNECTION *conn, const char *id)
 Allocate a dynamic statement.
 
TDSLOCALEtds_alloc_locale (void)
 
TDSLOGINtds_alloc_login (int use_environment)
 
char * tds_alloc_lookup_sqlstate (TDSSOCKET *tds, int msgno)
 
TDSPACKETtds_alloc_packet (void *buf, unsigned len)
 
void * tds_alloc_param_data (TDSCOLUMN *curparam)
 Allocate data for a parameter.
 
TDSPARAMINFOtds_alloc_param_result (TDSPARAMINFO *old_param)
 Adds a output parameter to TDSPARAMINFO.
 
TDSRESULTINFOtds_alloc_results (TDS_USMALLINT num_cols)
 
TDSRET tds_alloc_row (TDSRESULTINFO *res_info)
 Allocate space for row store return NULL on out of memory.
 
TDSSOCKETtds_alloc_socket (TDSCONTEXT *context, unsigned int bufsize)
 
 TDS_COMPILE_CHECK (tds_cap_len, sizeof(defaultcaps)==TDS_MAX_CAPABILITY)
 
 TDS_COMPILE_CHECK (tds_values_len, sizeof(defaultcaps.types[0].values)==14)
 
static void tds_connection_remove_socket (TDSCONNECTION *conn, TDSSOCKET *tds)
 
void tds_cursor_deallocated (TDSCONNECTION *conn, TDSCURSOR *cursor)
 
void tds_deinit_bcpinfo (TDSBCPINFO *bcpinfo)
 
static void tds_deinit_connection (TDSCONNECTION *conn)
 
void tds_deinit_tvp (TDS_TVP *table)
 
void tds_detach_results (TDSRESULTINFO *info)
 Detach result info from it current socket.
 
void tds_dynamic_deallocated (TDSCONNECTION *conn, TDSDYNAMIC *dyn)
 
void tds_free_all_results (TDSSOCKET *tds)
 
void tds_free_bcp_column_data (BCPCOLDATA *coldata)
 
void tds_free_bcpinfo (TDSBCPINFO *bcpinfo)
 
static void tds_free_column (TDSCOLUMN *col)
 
static void tds_free_compute_result (TDSCOMPUTEINFO *comp_info)
 
static void tds_free_compute_results (TDSSOCKET *tds)
 
void tds_free_context (TDSCONTEXT *context)
 
static void tds_free_env (TDSCONNECTION *conn)
 
void tds_free_input_params (TDSDYNAMIC *dyn)
 Frees all allocated input parameters of a dynamic statement.
 
void tds_free_locale (TDSLOCALE *locale)
 
void tds_free_login (TDSLOGIN *login)
 
void tds_free_msg (TDSMESSAGE *message)
 
void tds_free_packets (TDSPACKET *packet)
 
void tds_free_param_result (TDSPARAMINFO *param_info)
 Delete latest parameter.
 
void tds_free_param_results (TDSPARAMINFO *param_info)
 
void tds_free_results (TDSRESULTINFO *res_info)
 
void tds_free_row (TDSRESULTINFO *res_info, unsigned char *row)
 
void tds_free_socket (TDSSOCKET *tds)
 
static void tds_free_tvp_row (TDS_TVP_ROW *row)
 
static char * tds_get_dynid (TDSCONNECTION *conn, char *id)
 Get an id for dynamic query based on TDS information.
 
static TDSCONNECTIONtds_init_connection (TDSCONNECTION *conn, TDSCONTEXT *context, unsigned int bufsize)
 
TDSLOGINtds_init_login (TDSLOGIN *login, TDSLOCALE *locale)
 Initialize login structure with locale information and other stuff for connection.
 
static TDSSOCKETtds_init_socket (TDSSOCKET *tds_socket, unsigned int bufsize)
 
static void tds_param_free (TDSCOLUMN *col)
 
void * tds_realloc (void **pp, size_t new_size)
 Reallocate a pointer and update it if success.
 
TDSPACKETtds_realloc_packet (TDSPACKET *packet, unsigned len)
 
TDSSOCKETtds_realloc_socket (TDSSOCKET *tds, size_t bufsize)
 
void tds_release_cursor (TDSCURSOR **pcursor)
 
void tds_release_dynamic (TDSDYNAMIC **pdyn)
 Frees dynamic statement.
 
static void tds_row_free (TDSRESULTINFO *res_info, unsigned char *row)
 
void tds_set_current_results (TDSSOCKET *tds, TDSRESULTINFO *info)
 
static int winsock_initialized (void)
 

Variables

static const TDS_CAPABILITIES defaultcaps
 
static volatile unsigned int inc_num = 1
 
const TDSCOLUMNFUNCS tds_invalid_funcs
 

Detailed Description

Allocate or free resources.

Allocation can fail only on out of memory. In such case they return NULL and leave the state as before call. Mainly function names are in the form tds_alloc_XX or tds_free_XXX. tds_alloc_XXX functions allocate structures and return pointer to allocated data while tds_free_XXX take structure pointers and free them. Some functions require additional parameters to initialize structure correctly. The main exception are structures that use reference counting. These structures have tds_alloc_XXX functions but instead of tds_free_XXX use tds_release_XXX.

Macro Definition Documentation

◆ SUPPORTED_REQ_CAP

#define SUPPORTED_REQ_CAP (   i)
Value:
REQ(i,LANG) REQ(i,RPC) REQ(i,EVT) REQ(i,MSTMT) REQ(i,BCP) REQ(i,CURSOR) REQ(i,DYNF) \
REQ(i,MSG) REQ(i,PARAM) REQ(i,DATA_INT1) REQ(i,DATA_INT2) REQ(i,DATA_INT4) REQ(i,DATA_BIT) \
REQ(i,DATA_CHAR) REQ(i,DATA_VCHAR) REQ(i,DATA_BIN) REQ(i,DATA_VBIN) REQ(i,DATA_MNY8) \
REQ(i,DATA_MNY4) REQ(i,DATA_DATE8) REQ(i,DATA_DATE4) REQ(i,DATA_FLT4) REQ(i,DATA_FLT8) \
REQ(i,DATA_NUM) REQ(i,DATA_TEXT) REQ(i,DATA_IMAGE) REQ(i,DATA_DEC) REQ(i,DATA_LCHAR) \
REQ(i,DATA_LBIN) REQ(i,DATA_INTN) REQ(i,DATA_DATETIMEN) REQ(i,DATA_MONEYN) \
REQ(i,CSR_PREV) REQ(i,CSR_FIRST) REQ(i,CSR_LAST) REQ(i,CSR_ABS) REQ(i,CSR_REL) \
REQ(i,CSR_MULTI) REQ(i,CON_INBAND) REQ(i,PROTO_TEXT) REQ(i,PROTO_BULK) \
REQ(i,DATA_SENSITIVITY) REQ(i,DATA_BOUNDARY) REQ(i,PROTO_DYNPROC) REQ(i,DATA_FLTN) \
REQ(i,DATA_BITN) REQ(i,DATA_INT8) REQ(i,WIDETABLE) \
REQ(i,DATA_UINT2) REQ(i,DATA_UINT4) REQ(i,DATA_UINT8) REQ(i,DATA_UINTN) REQ(i,LARGEIDENT) \
REQ(i,SRVPKTSIZE) REQ(i,DATA_DATE) REQ(i,DATA_TIME) REQ(i,DATA_BIGTIME) REQ(i,DATA_BIGDATETIME)

Function Documentation

◆ tds_alloc_dynamic()

TDSDYNAMIC * tds_alloc_dynamic ( TDSCONNECTION conn,
const char *  id 
)

Allocate a dynamic statement.

Parameters
connthe connection within which to allocate the statement.
ida character label identifying the statement.
Returns
a pointer to the allocated structure (NULL on failure).

tds_alloc_dynamic is used to implement placeholder code under TDS 5.0

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tds_alloc_param_data()

void * tds_alloc_param_data ( TDSCOLUMN curparam)

Allocate data for a parameter.

Parameters
curparamparameter to retrieve size information
Returns
NULL on failure or new data
Here is the caller graph for this function:

◆ tds_alloc_param_result()

TDSPARAMINFO * tds_alloc_param_result ( TDSPARAMINFO old_param)

Adds a output parameter to TDSPARAMINFO.

Parameters
old_parama pointer to the TDSPARAMINFO structure containing the current set of output parameter, or NULL if none exists.
Returns
a pointer to the new TDSPARAMINFO structure.

tds_alloc_param_result() works a bit differently than the other alloc result functions. Output parameters come in individually with no total number given in advance, so we simply call this func every time with get a TDS_PARAM_TOKEN and let it realloc the columns struct one bigger. tds_free_all_results() usually cleans up after us.

Here is the caller graph for this function:

◆ tds_free_input_params()

void tds_free_input_params ( TDSDYNAMIC dyn)

Frees all allocated input parameters of a dynamic statement.

Parameters
dynthe dynamic statement whose input parameter are to be freed

tds_free_input_params frees all parameters for the give dynamic statement

Here is the caller graph for this function:

◆ tds_get_dynid()

static char * tds_get_dynid ( TDSCONNECTION conn,
char *  id 
)
static

Get an id for dynamic query based on TDS information.

Parameters
connstate information for the connection and the TDS protocol
Returns
TDS_FAIL or TDS_SUCCESS
Here is the caller graph for this function:

◆ tds_init_login()

TDSLOGIN * tds_init_login ( TDSLOGIN login,
TDSLOCALE locale 
)

Initialize login structure with locale information and other stuff for connection.

Parameters
localelocale information (copied to configuration information)
Returns
login structure or NULL if initialization error
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tds_realloc()

void * tds_realloc ( void **  pp,
size_t  new_size 
)

Reallocate a pointer and update it if success.

Parameters
pppointer to pointer to be reallocated
new_sizenew size to be allocated
Returns
new pointer allocated, NULL on failure
Here is the caller graph for this function:

◆ tds_release_dynamic()

void tds_release_dynamic ( TDSDYNAMIC **  pdyn)

Frees dynamic statement.

Parameters
pdynpointer to dynamic statement to be freed.
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ defaultcaps

const TDS_CAPABILITIES defaultcaps
static
Initial value:
= { {
{ 1, 14, { REQB(13), REQB(12), REQB(11), REQB(10), REQB(9), REQB(8), REQB(7),
REQB(6), REQB(5), REQB(4), REQB(3), REQB(2), REQB(1), REQB(0) } },
{ 2, 14, { RESB(13), RESB(12), RESB(11), RESB(10), RESB(9), RESB(8), RESB(7),
RESB(6), RESB(5), RESB(4), RESB(3), RESB(2), RESB(1), RESB(0) } }
} }