Example #1
0
/*!
  \brief Allocate array of handles

  \param count number of handles in the array

  \return pointer to first dbHandle in the array
*/
dbHandle *db_alloc_handle_array(int count)
{
    int i;
    dbHandle *handle;

    handle = (dbHandle *) db_calloc(count, sizeof(dbHandle));
    if (handle)
	for (i = 0; i < count; i++)
	    db_init_handle(&handle[i]);
    return handle;
}
Example #2
0
/*!
  \brief Allocate index array

  \param count number of items

  \return pointer to allocated dbIndex array
*/
dbIndex *db_alloc_index_array(int count)
{
    dbIndex *list;
    int i;

    list = (dbIndex *) db_calloc(count, sizeof(dbIndex));
    if (list) {
	for (i = 0; i < count; i++)
	    db_init_index(&list[i]);
    }
    return list;
}
Example #3
0
/* caller is responsible for free() */
int db__recv_float_array(float **x, int *n)
{
    int stat = DB_OK;
    int count = 0;
    float *a = NULL;

    if (!db__recv(&count, sizeof(count)))
	stat = DB_PROTOCOL_ERR;

    *n = count;

    *x = a = (float *)db_calloc(count, sizeof(*a));

    if (!db__recv(a, count * sizeof(*a)))
	stat = DB_PROTOCOL_ERR;

    if (stat == DB_PROTOCOL_ERR)
	db_protocol_error();

    return stat;
}