From: Karryanna Date: Mon, 29 Jun 2015 15:00:29 +0000 (+0200) Subject: Labeller: use xmalloc instead of malloc X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=456b35635ec50a7e8c0b6995e2a40675d469f6ae;p=leo.git Labeller: use xmalloc instead of malloc --- diff --git a/labeller.c b/labeller.c index 80d69e8..f9eb4a8 100644 --- a/labeller.c +++ b/labeller.c @@ -269,14 +269,14 @@ void make_bitmap_icon(struct variant *v, struct sym_icon *si) { v->width = si->sir.width + 1; v->height = si->sir.height + 1; - v->bitmap = malloc(v->width * v->height * sizeof(bool)); + v->bitmap = xmalloc(v->width * v->height * sizeof(bool)); for (int i=0; iwidth*v->height; i++) v->bitmap[i] = 1; } void make_bitmap_point(struct variant *v, struct sym_point *sp) { v->width = v->height = sp->size + 1; - v->bitmap = malloc(v->width * v->height * sizeof(bool)); + v->bitmap = xmalloc(v->width * v->height * sizeof(bool)); // FIXME: Okay, memset would be much nicer here for (int i=0; isize*sp->size; i++) v->bitmap[i] = 1; } @@ -310,7 +310,7 @@ void make_bitmap_label(struct variant *v, struct sym_text *text) v->width = max_x - min_x + 1; v->height = max_y - min_y + 1; - v->bitmap = malloc(v->width * v->height * sizeof(bool)); + v->bitmap = xmalloc(v->width * v->height * sizeof(bool)); memset(v->bitmap, 0, v->width * v->height * sizeof(bool)); for (int i=0; i= VERBOSITY_PLACEMENT) printf("Cutting [%.2f; %.2f] -- [%.2f; %.2f] to dist %.2f\n", e->n1->o->x, e->n1->o->y, e->n2->o->x, e->n2->o->y, dist); - struct graph_edge *new = malloc(sizeof(struct graph_edge)); + struct graph_edge *new = xmalloc(sizeof(struct graph_edge)); *new = *e; e->next = new; switch (e->label->type) { case SYMBOLIZER_TEXT: - new->label = malloc(sizeof(struct sym_text)); + new->label = xmalloc(sizeof(struct sym_text)); *((struct sym_text *) new->label) = *((struct sym_text *) e->label); break; default: @@ -786,8 +786,8 @@ void cut_edge(struct graph_edge *e, double dist) return; } - struct osm_node *n11 = malloc(sizeof(struct osm_node)); - struct graph_node *gn = malloc(sizeof(struct graph_node)); + struct osm_node *n11 = xmalloc(sizeof(struct osm_node)); + struct graph_node *gn = xmalloc(sizeof(struct graph_node)); gn->o = n11; double vsize = sqrt(pow(n1->x - n2->x, 2) + pow(n1->y - n2->y, 2)); n11->x = n1->x + (n2->x - n1->x) / vsize * dist; @@ -861,7 +861,7 @@ void make_segments(void) } rs = make_new_segment(rls, NULL); - rs->label = malloc(sizeof(struct sym_text)); + rs->label = xmalloc(sizeof(struct sym_text)); *((struct sym_text *) rs->label) = *((struct sym_text *) e->label); rs->x1 = e->n1->o->x; @@ -936,7 +936,7 @@ void dump_linelabel_requests(void) void dump_bitmaps(struct individual *individual) { - bool *bitmap = malloc(page_width_int * page_height_int * sizeof(bool)); + bool *bitmap = xmalloc(page_width_int * page_height_int * sizeof(bool)); printf("Bitmap size is %d\n", page_width_int * page_height_int); for (int i=0; iplacement = p; mp->part = parts[i]; @@ -1863,7 +1863,7 @@ struct placement **get_closure(struct placement *placement) { struct placement **closure; GARY_INIT(closure, 0); - bool *chosen = malloc(GARY_SIZE(placement->individual->placements) * sizeof(bool)); + bool *chosen = xmalloc(GARY_SIZE(placement->individual->placements) * sizeof(bool)); for (uns i=0; iindividual->placements); i++) { chosen[i] = 0; } chosen[placement->request->ind] = 1; @@ -2033,10 +2033,10 @@ void reset_individual_map(struct individual *i) } free(i->map[j]); - struct map_part *part = malloc(sizeof(struct map_part)); + struct map_part *part = xmalloc(sizeof(struct map_part)); part->ind = j; - mp = malloc(sizeof(struct map_placement)); + mp = xmalloc(sizeof(struct map_placement)); part->placement = mp; mp->placement = &dummy_placement; mp->next_in_map = mp->prev_in_map = NULL; @@ -2145,8 +2145,8 @@ void init_individual(struct individual *individual) for (uns j=0; jmap); - struct map_part *part = malloc(sizeof(struct map_part)); - struct map_placement *mp = malloc(sizeof(struct map_placement)); + struct map_part *part = xmalloc(sizeof(struct map_part)); + struct map_placement *mp = xmalloc(sizeof(struct map_placement)); part->placement = mp; part->ind = j; mp->placement = &dummy_placement;