{
struct coord_rect *r=g_new(struct coord_rect, 1);
- g_assert(lu->x <= rl->x);
- g_assert(lu->y >= rl->y);
+ dbg_assert(lu->x <= rl->x);
+ dbg_assert(lu->y >= rl->y);
r->lu=*lu;
r->rl=*rl;
int
coord_rect_overlap(struct coord_rect *r1, struct coord_rect *r2)
{
- g_assert(r1->lu.x <= r1->rl.x);
- g_assert(r1->lu.y >= r1->rl.y);
- g_assert(r2->lu.x <= r2->rl.x);
- g_assert(r2->lu.y >= r2->rl.y);
+ dbg_assert(r1->lu.x <= r1->rl.x);
+ dbg_assert(r1->lu.y >= r1->rl.y);
+ dbg_assert(r2->lu.x <= r2->rl.x);
+ dbg_assert(r2->lu.y >= r2->rl.y);
dbg(1,"0x%x,0x%x - 0x%x,0x%x vs 0x%x,0x%x - 0x%x,0x%x\n", r1->lu.x, r1->lu.y, r1->rl.x, r1->rl.y, r2->lu.x, r2->lu.y, r2->rl.x, r2->rl.y);
if (r1->lu.x > r2->rl.x)
return 0;
int
coord_rect_contains(struct coord_rect *r, struct coord *c)
{
- g_assert(r->lu.x <= r->rl.x);
- g_assert(r->lu.y >= r->rl.y);
+ dbg_assert(r->lu.x <= r->rl.x);
+ dbg_assert(r->lu.y >= r->rl.y);
if (c->x < r->lu.x)
return 0;
if (c->x > r->rl.x)
va_end(ap);
}
-
+void
+debug_assert_fail(char *module, const int mlen,const char *function, const int flen, char *file, int line, char *expr)
+{
+ debug_printf(0,module,mlen,function,flen,1,"%s:%d assertion failed:%s\n", file, line, expr);
+ abort();
+}
#define dbg_str1(x) dbg_str2(x)
#define dbg_module dbg_str1(MODULE)
#define dbg(level,fmt...) ({ if (debug_level >= level) debug_printf(level,dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),1,fmt); })
+#define dbg_assert(expr) ((expr) ? (void) 0 : debug_assert_fail(dbg_module,strlen(dbg_module),__PRETTY_FUNCTION__, strlen(__PRETTY_FUNCTION__),__FILE__,__LINE__,dbg_str1(expr)))
/* prototypes */
void debug_init(const char *program_name);
int debug_level_get(const char *name);
void debug_vprintf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, va_list ap);
void debug_printf(int level, const char *module, const int mlen, const char *function, const int flen, int prefix, const char *fmt, ...);
+void debug_assert_fail(char *module, const int mlen,const char *function, const int flen, char *file, int line, char *expr);
/* end of prototypes */
#ifdef __cplusplus
fstat(file->fd, &stat);
file->size=stat.st_size;
file->name = g_strdup(name);
- g_assert(file != NULL);
+ dbg_assert(file != NULL);
file->next=file_list;
file_list=file;
return file;
file->begin = (char*)mmap_readonly_win32( file->name, &file->map_handle, &file->map_file );
#else
file->begin=mmap(NULL, file->size, PROT_READ|PROT_WRITE, MAP_PRIVATE, file->fd, 0);
- g_assert(file->begin != NULL);
+ dbg_assert(file->begin != NULL);
if (file->begin == (void *)0xffffffff) {
perror("mmap");
return 0;
}
#endif
- g_assert(file->begin != (void *)0xffffffff);
+ dbg_assert(file->begin != (void *)0xffffffff);
file->end=file->begin+file->size;
return 1;
map_rect_get_item(struct map_rect *mr)
{
struct item *ret;
- g_assert(mr != NULL);
- g_assert(mr->m != NULL);
- g_assert(mr->m->meth.map_rect_get_item != NULL);
+ dbg_assert(mr != NULL);
+ dbg_assert(mr->m != NULL);
+ dbg_assert(mr->m->meth.map_rect_get_item != NULL);
ret=mr->m->meth.map_rect_get_item(mr->priv);
if (ret)
ret->map=mr->m;
map_rect_get_item_byid(struct map_rect *mr, int id_hi, int id_lo)
{
struct item *ret=NULL;
- g_assert(mr != NULL);
- g_assert(mr->m != NULL);
+ dbg_assert(mr != NULL);
+ dbg_assert(mr->m != NULL);
if (mr->m->meth.map_rect_get_item_byid)
ret=mr->m->meth.map_rect_get_item_byid(mr->priv, id_hi, id_lo);
if (ret)
s->end=end;
s->end_next=end->end;
end->end=s;
- g_assert(len >= 0);
+ dbg_assert(len >= 0);
s->len=len;
s->item=*item;
s->flags=flags;
if (len < 0) {
printf("len=%d\n", len);
}
- g_assert(len >= 0);
+ dbg_assert(len >= 0);
ret=route_time(speedlist, item, len);
dbg(1, "route_value(0x%x, %d)=%d\n", item->type, len, ret);
return ret;
l=c;
}
e_pnt=route_graph_add_point(this,&l);
- g_assert(len >= 0);
+ dbg_assert(len >= 0);
route_graph_add_segment(this, s_pnt, e_pnt, len, item, flags, offset);
} else {
int isseg,rc;
}
} while(rc);
e_pnt=route_graph_add_point(this,&l);
- g_assert(len >= 0);
+ dbg_assert(len >= 0);
sc++;
route_graph_add_segment(this, s_pnt, e_pnt, len, item, flags, offset);
}
if (! (sd->flags & AF_ONEWAYREV)) { /* If we may drive in the direction of the coordinates of the item, the first coordinate is one starting point */
end=route_graph_get_point(this, &sd->c[0]);
- g_assert(end != 0);
+ dbg_assert(end != 0);
end->value=route_value(speedlist, &sd->item, dst->lenneg);
end->el=fh_insert(heap, end);
}
if (! (sd->flags & AF_ONEWAY)) { /* If we may drive against the direction of the coordinates, the last coordinate is another starting point */
end=route_graph_get_point(this, &sd->c[sd->count-1]);
- g_assert(end != 0);
+ dbg_assert(end != 0);
end->value=route_value(speedlist, &sd->item, dst->lenpos);
end->el=fh_insert(heap, end);
}
if (item_attr_get(item, attr_debug, &attr))
dbg(0,"debug='%s'\n", attr.u.str);
}
- g_assert(count < maxcount);
+ dbg_assert(count < maxcount);
ret=g_malloc(sizeof(struct street_data)+count*sizeof(struct coord));
ret->item=*item;
ret->count=count;