MCPcopy Create free account
hub / github.com/Meituan-Dianping/SQLAdvisor / my_error_register

Function my_error_register

mysys/my_error.c:301–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299*/
300
301int 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/**

Callers 3

ha_init_errorsFunction · 0.85
init_errmessageFunction · 0.85

Calls 2

my_mallocFunction · 0.85
my_freeFunction · 0.85

Tested by

no test coverage detected