+ /* mips32_..._write_mem with size 4/2 requires uint32_t/uint16_t in host */
+ /* endianness, but byte array represents target endianness */
+ uint8_t * t = NULL;
+ t = malloc(count * sizeof(uint32_t));
+ if (t == NULL)
+ {
+ LOG_ERROR("Out of memory");
+ return ERROR_FAIL;
+ }
+
+ uint32_t i, t32;
+ uint16_t t16;
+ for(i = 0; i < (count*size); i += size)
+ {
+ switch(size)
+ {
+ case 4:
+ t32 = target_buffer_get_u32(target,&buffer[i]);
+ *(uint32_t*)&t[i] = t32;
+ break;
+ case 2:
+ t16 = target_buffer_get_u16(target,&buffer[i]);
+ *(uint16_t*)&t[i] = t16;
+ break;
+ }
+ }
+ buffer = t;
+