~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to examples/pipe_query.c

  • Committer: Monty Taylor
  • Author(s): Stewart Smith
  • Date: 2010-11-08 05:36:30 UTC
  • mto: This revision was merged to the branch mainline in revision 1931.
  • Revision ID: stewart@flamingspork.com-20101108053630-emuzl3phvfr3cm8y
fix large stack usage in example/pipe_query.c

examples/pipe_query.c: In function main:
examples/pipe_query.c:173: error: the frame size of 38864 bytes is larger than 32768 bytes [-Wframe-larger-than=]

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
  size_t buffer_total= 0;
33
33
  ssize_t read_size= 0;
34
34
  drizzle_st drizzle;
35
 
  drizzle_con_st con;
 
35
  drizzle_con_st *con= (drizzle_con_st*)malloc(sizeof(drizzle_con_st));
36
36
  drizzle_result_st result;
37
37
  drizzle_return_t ret;
38
38
  drizzle_field_t field;
40
40
  size_t size;
41
41
  size_t total;
42
42
 
 
43
  if (con == NULL)
 
44
  {
 
45
    printf("Failed to allocate memory for drizzle connection");
 
46
    exit(1);
 
47
  }
 
48
 
43
49
  /* The docs say this might fail, so check for errors. */
44
50
  if (drizzle_create(&drizzle) == NULL)
45
51
  {
47
53
    exit(1);
48
54
  }
49
55
 
50
 
  if (drizzle_con_create(&drizzle, &con) == NULL)
 
56
  if (drizzle_con_create(&drizzle, con) == NULL)
51
57
  {
52
58
    printf("drizzle_con_create:%s\n", drizzle_error(&drizzle));
53
59
    exit(1);
58
64
    switch(c)
59
65
    {
60
66
    case 'd':
61
 
      drizzle_con_set_db(&con, optarg);
 
67
      drizzle_con_set_db(con, optarg);
62
68
      break;
63
69
 
64
70
    case 'h':
66
72
      break;
67
73
 
68
74
    case 'm':
69
 
      drizzle_con_add_options(&con, DRIZZLE_CON_MYSQL);
 
75
      drizzle_con_add_options(con, DRIZZLE_CON_MYSQL);
70
76
      break;
71
77
 
72
78
    case 'p':
95
101
    }
96
102
  }
97
103
 
98
 
  drizzle_con_set_tcp(&con, host, port);
99
 
  drizzle_con_set_auth(&con, user, password);
 
104
  drizzle_con_set_tcp(con, host, port);
 
105
  drizzle_con_set_auth(con, user, password);
100
106
 
101
107
  do
102
108
  {
118
124
    buffer_total= buffer_size + BUFFER_CHUNK;
119
125
  } while ((read_size= read(0, buffer + buffer_size, BUFFER_CHUNK)) != 0);
120
126
 
121
 
  (void)drizzle_query(&con, &result, buffer, buffer_size, &ret);
 
127
  (void)drizzle_query(con, &result, buffer, buffer_size, &ret);
122
128
  if (ret != DRIZZLE_RETURN_OK)
123
129
  {
124
130
    printf("drizzle_query:%s\n", drizzle_error(&drizzle));
166
172
  }
167
173
 
168
174
  drizzle_result_free(&result);
169
 
  drizzle_con_free(&con);
 
175
  drizzle_con_free(con);
170
176
  drizzle_free(&drizzle);
171
177
 
 
178
  free(con);
172
179
  return 0;
173
180
}