~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/vio.c

  • Committer: Monty Taylor
  • Date: 2009-01-30 21:02:37 UTC
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 823.
  • Revision ID: mordred@inaugust.com-20090130210237-3n6ld8a9jc084jko
Commented out a test in subselect_sj - I think it might be a regression. Jay?

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  the file descriptior.
21
21
*/
22
22
 
23
 
#include "vio_priv.h"
 
23
#define DONT_MAP_VIO
 
24
#include <drizzled/global.h>
 
25
#include <libdrizzle/vio.h>
 
26
#include <string.h>
 
27
#include <stdint.h>
24
28
 
25
29
/*
26
30
 * Helper to fill most of the Vio* with defaults.
29
33
static void vio_init(Vio* vio, enum enum_vio_type type,
30
34
                     int sd, uint32_t flags)
31
35
{
32
 
#ifndef HAVE_VIO_READ_BUFF
33
 
  flags&= ~VIO_BUFFERED_READ;
34
 
#endif
35
36
  memset(vio, 0, sizeof(*vio));
36
37
  vio->type     = type;
37
38
  vio->sd       = sd;
38
39
  if ((flags & VIO_BUFFERED_READ) &&
39
 
      !(vio->read_buffer= (char*)my_malloc(VIO_READ_BUFFER_SIZE, MYF(MY_WME))))
 
40
      !(vio->read_buffer= (char*)malloc(VIO_READ_BUFFER_SIZE)))
40
41
    flags&= ~VIO_BUFFERED_READ;
41
42
  {
42
43
    vio->viodelete      =vio_delete;
59
60
/* Reset initialized VIO to use with another transport type */
60
61
 
61
62
void vio_reset(Vio* vio, enum enum_vio_type type,
62
 
               int sd, uint flags)
 
63
               int sd, uint32_t flags)
63
64
{
64
 
  my_free(vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
 
65
  free(vio->read_buffer);
65
66
  vio_init(vio, type, sd, flags);
66
67
}
67
68
 
68
69
 
69
70
/* Open the socket or TCP/IP connection and read the fnctl() status */
70
71
 
71
 
Vio *vio_new(int sd, enum enum_vio_type type, uint flags)
 
72
Vio *vio_new(int sd, enum enum_vio_type type, uint32_t flags)
72
73
{
73
 
  Vio *vio;
 
74
  Vio *vio = (Vio*) malloc(sizeof(Vio));
74
75
 
75
 
  if ((vio = (Vio*) my_malloc(sizeof(*vio),MYF(MY_WME))))
 
76
  if (vio != NULL)
76
77
  {
77
78
    vio_init(vio, type, sd, flags);
78
79
    sprintf(vio->desc, "TCP/IP (%d)", vio->sd);
100
101
 
101
102
  if (vio->type != VIO_CLOSED)
102
103
    vio->vioclose(vio);
103
 
  my_free((uchar*) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR));
104
 
  my_free((uchar*) vio, MYF(0));
 
104
  free((unsigned char*) vio->read_buffer);
 
105
  free((unsigned char*) vio);
105
106
}
106
107
 
107
108