← Back to team overview

maria-developers team mailing list archive

Review: MWL#36 diff

 

Hi!

>>>>> "Sergey" == Sergey Petrunya <psergey@xxxxxxxxxxxx> writes:

<cut>

Sergey> Log_event* Log_event::read_log_event(IO_CACHE* file,
Sergey>                                      const Format_description_log_event
Sergey>                                      *description_event)

Sergey> which has this code:
Sergey>   // some events use the extra byte to null-terminate strings
Sergey>   if (!(buf = (char*) my_malloc(data_len+1, MYF(MY_WME))))
Sergey>   {
Sergey>     error = "Out of memory";
Sergey>     goto err;
Sergey>   }
Sergey>   buf[data_len] = 0;
Sergey>   memcpy(buf, head, header_size);

Short note:

You can replace all of the above with:

if (!(buf= (char*) my_strndup(head, header_size, MYF(MY_WME))))
  goto err;

Note that my_strndup() when used with the MY_WME flag will generate an
error message itself!

<cut>

Regards,
Monty



References