From db52fe692315470d22e525ce37da32fd207abbb3 Mon Sep 17 00:00:00 2001 From: Gabriel Ebner Date: Sun, 4 May 2008 12:03:05 +0000 Subject: [PATCH] api06: Use 2-byte ints and check malloc return value. --- db/migrate/013_populate_node_tags_and_remove_helper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/db/migrate/013_populate_node_tags_and_remove_helper.c b/db/migrate/013_populate_node_tags_and_remove_helper.c index 26a8f71df..e0e8bb3f7 100644 --- a/db/migrate/013_populate_node_tags_and_remove_helper.c +++ b/db/migrate/013_populate_node_tags_and_remove_helper.c @@ -85,7 +85,7 @@ static int read_node_tags(char **tags, char **k, char **v) { struct data { MYSQL *mysql; size_t version_size; - uint32_t *version; + uint16_t *version; }; static void proc_nodes(struct data *d, const char *tbl, FILE *out, FILE *out_tags, int hist) { @@ -198,8 +198,13 @@ int main(int argc, char **argv) { d->mysql = connect_to_mysql(argv); d->version_size = 1 + select_size(d->mysql, "SELECT max(id) FROM current_nodes"); - d->version = malloc(sizeof(uint32_t) * d->version_size); - memset(d->version, 0, sizeof(uint32_t) * d->version_size); + d->version = (uint16_t *) malloc(sizeof(uint16_t) * d->version_size); + if (!d->version) { + perror("malloc"); + abort(); + exit(EXIT_FAILURE); + } + memset(d->version, 0, sizeof(uint16_t) * d->version_size); prefix_len = strlen(argv[7]); tempfn = (char *) malloc(prefix_len + 32); -- 2.39.5