| 1607 | */ |
| 1608 | |
| 1609 | int my_b_append(register IO_CACHE *info, const uchar *Buffer, size_t Count) |
| 1610 | { |
| 1611 | size_t rest_length,length; |
| 1612 | |
| 1613 | /* |
| 1614 | Assert that we cannot come here with a shared cache. If we do one |
| 1615 | day, we might need to add a call to copy_to_read_buffer(). |
| 1616 | */ |
| 1617 | DBUG_ASSERT(!info->share); |
| 1618 | |
| 1619 | lock_append_buffer(info); |
| 1620 | rest_length= (size_t) (info->write_end - info->write_pos); |
| 1621 | if (Count <= rest_length) |
| 1622 | goto end; |
| 1623 | memcpy(info->write_pos, Buffer, rest_length); |
| 1624 | Buffer+=rest_length; |
| 1625 | Count-=rest_length; |
| 1626 | info->write_pos+=rest_length; |
| 1627 | if (my_b_flush_io_cache(info,0)) |
| 1628 | { |
| 1629 | unlock_append_buffer(info); |
| 1630 | return 1; |
| 1631 | } |
| 1632 | if (Count >= IO_SIZE) |
| 1633 | { /* Fill first intern buffer */ |
| 1634 | length=Count & (size_t) ~(IO_SIZE-1); |
| 1635 | if (mysql_file_write(info->file,Buffer, length, info->myflags | MY_NABP)) |
| 1636 | { |
| 1637 | unlock_append_buffer(info); |
| 1638 | return info->error= -1; |
| 1639 | } |
| 1640 | Count-=length; |
| 1641 | Buffer+=length; |
| 1642 | info->end_of_file+=length; |
| 1643 | } |
| 1644 | |
| 1645 | end: |
| 1646 | memcpy(info->write_pos,Buffer,(size_t) Count); |
| 1647 | info->write_pos+=Count; |
| 1648 | unlock_append_buffer(info); |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | |
| 1653 | int my_b_safe_write(IO_CACHE *info, const uchar *Buffer, size_t Count) |
no test coverage detected