- /* or1k_write_memory with size 4/2 requires uint32_t/uint16_t in host */
- /* endianness, but byte array represents target endianness */
-
- void *t = NULL;
- if (size > 1) {
- t = malloc(count * size * sizeof(uint8_t));
- if (t == NULL) {
- LOG_ERROR("Out of memory");
- return ERROR_FAIL;
- }
-
- switch (size) {
- case 4:
- target_buffer_get_u32_array(target, buffer, count, (uint32_t *)t);
- break;
- case 2:
- target_buffer_get_u16_array(target, buffer, count, (uint16_t *)t);
- break;
- }
- buffer = t;
- }
-
- int retval = du_core->or1k_jtag_write_memory(&or1k->jtag, address, size, count, buffer);
-
- if (t != NULL)
- free(t);
-
- if (retval != ERROR_OK)
- return retval;
-
- return ERROR_OK;
+ return du_core->or1k_jtag_write_memory(&or1k->jtag, address, size, count, buffer);