We don't assume sizeof(struct node_id) == sizeof(struct node_id.k), * otherwise this would simply be a call to db_col_arr! * Thanks ARM! */
| 377 | * otherwise this would simply be a call to db_col_arr! |
| 378 | * Thanks ARM! */ |
| 379 | struct node_id *db_col_node_id_arr(const tal_t *ctx, struct db_stmt *stmt, |
| 380 | const char *colname) |
| 381 | { |
| 382 | size_t col = db_query_colnum(stmt, colname); |
| 383 | struct node_id *ret; |
| 384 | size_t n = db_column_bytes(stmt, col) / sizeof(ret->k); |
| 385 | const u8 *arr = db_column_blob(stmt, col); |
| 386 | assert(n * sizeof(ret->k) == (size_t)db_column_bytes(stmt, col)); |
| 387 | |
| 388 | if (db_column_is_null(stmt, col)) |
| 389 | return NULL; |
| 390 | |
| 391 | ret = tal_arr(ctx, struct node_id, n); |
| 392 | for (size_t i = 0; i < n; i++) |
| 393 | memcpy(ret[i].k, arr + i * sizeof(ret[i].k), sizeof(ret[i].k)); |
| 394 | |
| 395 | return ret; |
| 396 | } |
| 397 | |
| 398 | void db_col_pubkey(struct db_stmt *stmt, |
| 399 | const char *colname, |
no test coverage detected