| 299 | */ |
| 300 | |
| 301 | int my_error_register(const char** (*get_errmsgs) (), int first, int last) |
| 302 | { |
| 303 | struct my_err_head *meh_p; |
| 304 | struct my_err_head **search_meh_pp; |
| 305 | |
| 306 | /* Allocate a new header structure. */ |
| 307 | if (! (meh_p= (struct my_err_head*) my_malloc(sizeof(struct my_err_head), |
| 308 | MYF(MY_WME)))) |
| 309 | return 1; |
| 310 | meh_p->get_errmsgs= get_errmsgs; |
| 311 | meh_p->meh_first= first; |
| 312 | meh_p->meh_last= last; |
| 313 | |
| 314 | /* Search for the right position in the list. */ |
| 315 | for (search_meh_pp= &my_errmsgs_list; |
| 316 | *search_meh_pp; |
| 317 | search_meh_pp= &(*search_meh_pp)->meh_next) |
| 318 | { |
| 319 | if ((*search_meh_pp)->meh_last > first) |
| 320 | break; |
| 321 | } |
| 322 | |
| 323 | /* Error numbers must be unique. No overlapping is allowed. */ |
| 324 | if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last)) |
| 325 | { |
| 326 | my_free(meh_p); |
| 327 | return 1; |
| 328 | } |
| 329 | |
| 330 | /* Insert header into the chain. */ |
| 331 | meh_p->meh_next= *search_meh_pp; |
| 332 | *search_meh_pp= meh_p; |
| 333 | return 0; |
| 334 | } |
| 335 | |
| 336 | |
| 337 | /** |
no test coverage detected