}
else {
int hex_bytes_filled;
- UINT8 hexbuf[200];
+ UINT8 *hexbuf;
UINT16 len = (strlen(report) + 1) / 2;
+ hexbuf = GKI_getbuf(len);
+ if (hexbuf == NULL) {
+ BTIF_TRACE_ERROR2("%s: Error, failed to allocate RPT buffer, len = %d",
+ __FUNCTION__, len);
+ return BT_STATUS_FAIL;
+ }
+
/* Build a SetReport data buffer */
- memset(hexbuf, 0, 200);
+ memset(hexbuf, 0, len);
//TODO
hex_bytes_filled = ascii_2_hex(report, len, hexbuf);
BTIF_TRACE_DEBUG1("Hex bytes filled, hex value: %d", hex_bytes_filled);
if (p_buf == NULL) {
BTIF_TRACE_ERROR2("%s: Error, failed to allocate RPT buffer, len = %d",
__FUNCTION__, hex_bytes_filled);
+ GKI_freebuf(hexbuf);
return BT_STATUS_FAIL;
}
BTA_HhSetReport(p_dev->dev_handle, reportType, p_buf);
+ GKI_freebuf(hexbuf);
+ return BT_STATUS_SUCCESS;
}
- return BT_STATUS_SUCCESS;
+ GKI_freebuf(hexbuf);
+ return BT_STATUS_FAIL;
}
}