aboutsummaryrefslogtreecommitdiff
path: root/src/my/my_query_helper.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-06-13 11:40:29 +0000
committerChristian Grothoff <christian@grothoff.org>2016-06-13 11:40:29 +0000
commit0cf4193a34c4445b99b94c3c315d6a1361835cb6 (patch)
tree3bd216a81a7e0f33860c68a0905d90d363a37e4a /src/my/my_query_helper.c
parente290fbfbeae0a3bccf2c2dc68f5d37bc1f3c4f81 (diff)
downloadgnunet-0cf4193a34c4445b99b94c3c315d6a1361835cb6.tar.gz
gnunet-0cf4193a34c4445b99b94c3c315d6a1361835cb6.zip
fix indentation, bad stack allocation of buf
Diffstat (limited to 'src/my/my_query_helper.c')
-rw-r--r--src/my/my_query_helper.c50
1 files changed, 11 insertions, 39 deletions
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c
index 8ecfc2b64..c806a73fb 100644
--- a/src/my/my_query_helper.c
+++ b/src/my/my_query_helper.c
@@ -37,7 +37,7 @@
37 */ 37 */
38static void 38static void
39my_clean_query (void *cls, 39my_clean_query (void *cls,
40 MYSQL_BIND *qbind) 40 MYSQL_BIND *qbind)
41{ 41{
42 GNUNET_free (qbind[0].buffer); 42 GNUNET_free (qbind[0].buffer);
43} 43}
@@ -115,21 +115,10 @@ my_conv_uint16 (void *cls,
115 const struct GNUNET_MY_QueryParam * qp, 115 const struct GNUNET_MY_QueryParam * qp,
116 MYSQL_BIND *qbind) 116 MYSQL_BIND *qbind)
117{ 117{
118 const uint16_t *u_hbo = qp->data;
119 uint16_t *u_nbo;
120
121 GNUNET_assert (1 == qp->num_params); 118 GNUNET_assert (1 == qp->num_params);
122 119 qbind->buffer = (void *) qp->data;
123 u_nbo = GNUNET_new (uint16_t); 120 qbind->buffer_length = sizeof (uint16_t);
124 if (NULL == u_nbo)
125 return -1;
126
127 *u_nbo = *u_hbo;
128
129 qbind->buffer = (void *) u_nbo;
130 qbind->buffer_length = sizeof(uint16_t);
131 qbind->buffer_type = MYSQL_TYPE_SHORT; 121 qbind->buffer_type = MYSQL_TYPE_SHORT;
132
133 return 1; 122 return 1;
134} 123}
135 124
@@ -144,7 +133,7 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x)
144{ 133{
145 struct GNUNET_MY_QueryParam res = { 134 struct GNUNET_MY_QueryParam res = {
146 .conv = &my_conv_uint16, 135 .conv = &my_conv_uint16,
147 .cleaner = &my_clean_query, 136 .cleaner = NULL,
148 .conv_cls = NULL, 137 .conv_cls = NULL,
149 .num_params = 1, 138 .num_params = 1,
150 .data = x, 139 .data = x,
@@ -168,16 +157,8 @@ my_conv_uint32 (void *cls,
168 const struct GNUNET_MY_QueryParam *qp, 157 const struct GNUNET_MY_QueryParam *qp,
169 MYSQL_BIND *qbind) 158 MYSQL_BIND *qbind)
170{ 159{
171 const uint32_t *u_hbo = qp->data;
172 uint32_t * u_nbo;
173
174 GNUNET_assert (1 == qp->num_params); 160 GNUNET_assert (1 == qp->num_params);
175 161 qbind->buffer = (void *) qp->data;
176 u_nbo = GNUNET_new (uint32_t);
177
178 *u_nbo = *u_hbo;
179
180 qbind->buffer = (void *) u_nbo;
181 qbind->buffer_length = sizeof(uint32_t); 162 qbind->buffer_length = sizeof(uint32_t);
182 qbind->buffer_type = MYSQL_TYPE_LONG; 163 qbind->buffer_type = MYSQL_TYPE_LONG;
183 164
@@ -195,7 +176,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
195{ 176{
196 struct GNUNET_MY_QueryParam res = { 177 struct GNUNET_MY_QueryParam res = {
197 .conv = &my_conv_uint32, 178 .conv = &my_conv_uint32,
198 .cleaner = &my_clean_query, 179 .cleaner = NULL,
199 .conv_cls = NULL, 180 .conv_cls = NULL,
200 .num_params = 1, 181 .num_params = 1,
201 .data = x, 182 .data = x,
@@ -216,22 +197,13 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x)
216 */ 197 */
217static int 198static int
218my_conv_uint64 (void *cls, 199my_conv_uint64 (void *cls,
219 const struct GNUNET_MY_QueryParam *qp, 200 const struct GNUNET_MY_QueryParam *qp,
220 MYSQL_BIND * qbind) 201 MYSQL_BIND * qbind)
221{ 202{
222 const uint64_t * u_hbo = qp->data;
223 uint64_t *u_nbo;
224
225 GNUNET_assert (1 == qp->num_params); 203 GNUNET_assert (1 == qp->num_params);
226 204 qbind->buffer = (void *) qp->data;
227 u_nbo = GNUNET_new(uint64_t);
228
229 *u_nbo = *u_hbo;
230
231 qbind->buffer = (void *) u_nbo;
232 qbind->buffer_length = sizeof (uint64_t); 205 qbind->buffer_length = sizeof (uint64_t);
233 qbind->buffer_type = MYSQL_TYPE_LONGLONG; 206 qbind->buffer_type = MYSQL_TYPE_LONGLONG;
234
235 return 1; 207 return 1;
236} 208}
237 209
@@ -246,7 +218,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x)
246{ 218{
247 struct GNUNET_MY_QueryParam res = { 219 struct GNUNET_MY_QueryParam res = {
248 .conv = &my_conv_uint64, 220 .conv = &my_conv_uint64,
249 .cleaner = &my_clean_query, 221 .cleaner = NULL,
250 .conv_cls = NULL, 222 .conv_cls = NULL,
251 .num_params = 1, 223 .num_params = 1,
252 .data = x, 224 .data = x,
@@ -387,4 +359,4 @@ GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x
387} 359}
388 360
389 361
390/* end of my_query_helper.c */ \ No newline at end of file 362/* end of my_query_helper.c */