* garrow_mutable_buffer_set_data: * @buffer: A #GArrowMutableBuffer. * @offset: A write offset in the buffer data in byte. * @data: (array length=size): The data to be written. * @size: The number of bytes of the data to be written. * @error: (nullable): Return location for a #GError or %NULL. * * Returns: %TRUE on success, %FALSE otherwise. * * Since: 0.12.0 */
| 501 | * Since: 0.12.0 |
| 502 | */ |
| 503 | gboolean |
| 504 | garrow_mutable_buffer_set_data(GArrowMutableBuffer *buffer, |
| 505 | gint64 offset, |
| 506 | const guint8 *data, |
| 507 | gint64 size, |
| 508 | GError **error) |
| 509 | { |
| 510 | const gchar *context = "[mutable-buffer][set-data]"; |
| 511 | auto arrow_buffer = garrow_buffer_get_raw(GARROW_BUFFER(buffer)); |
| 512 | if (offset + size > arrow_buffer->size()) { |
| 513 | g_set_error(error, |
| 514 | GARROW_ERROR, |
| 515 | GARROW_ERROR_INVALID, |
| 516 | "%s: Data is too large: " |
| 517 | "<(%" G_GINT64_FORMAT " + %" G_GINT64_FORMAT ") > " |
| 518 | "(%" G_GINT64_FORMAT ")>", |
| 519 | context, |
| 520 | offset, |
| 521 | size, |
| 522 | arrow_buffer->size()); |
| 523 | return FALSE; |
| 524 | } |
| 525 | memcpy(arrow_buffer->mutable_data() + offset, data, size); |
| 526 | return TRUE; |
| 527 | } |
| 528 | |
| 529 | G_DEFINE_TYPE(GArrowResizableBuffer, garrow_resizable_buffer, GARROW_TYPE_MUTABLE_BUFFER) |
| 530 |
nothing calls this directly
no test coverage detected