Replaced osi_getbuf()/osi_freebuf() with osi_malloc()/osi_free()

Removed the alternative buffer allocation osi_getbuf() / osi_freebuf()
and use instead osi_malloc() / osi_free().

Correspondingly, replaced usage of osi_freebuf_and_reset()
with osi_free_and_reset().

Bug: 24914560
Change-Id: I7a9599ba7fa900321f087da684428133eb0ddd6b
diff --git a/stack/gatt/gatt_sr.c b/stack/gatt/gatt_sr.c
index d31d165..998e46e 100644
--- a/stack/gatt/gatt_sr.c
+++ b/stack/gatt/gatt_sr.c
@@ -101,10 +101,10 @@
     GATT_TRACE_DEBUG("gatt_dequeue_sr_cmd" );
     if (p_tcb->sr_cmd.p_rsp_msg)
         GATT_TRACE_ERROR("free p_tcb->sr_cmd.p_rsp_msg = %d", p_tcb->sr_cmd.p_rsp_msg);
-    osi_freebuf_and_reset((void **)&p_tcb->sr_cmd.p_rsp_msg);
+    osi_free_and_reset((void **)&p_tcb->sr_cmd.p_rsp_msg);
 
     while (!fixed_queue_is_empty(p_tcb->sr_cmd.multi_rsp_q))
-        osi_freebuf(fixed_queue_try_dequeue(p_tcb->sr_cmd.multi_rsp_q));
+        osi_free(fixed_queue_try_dequeue(p_tcb->sr_cmd.multi_rsp_q));
     fixed_queue_free(p_tcb->sr_cmd.multi_rsp_q, NULL);
     memset( &p_tcb->sr_cmd, 0, sizeof(tGATT_SR_CMD));
 }
@@ -122,7 +122,7 @@
                                        tGATTS_RSP *p_msg, UINT16 mtu)
 {
     UINT16          ii, total_len, len;
-    BT_HDR          *p_buf = (BT_HDR *)osi_getbuf((UINT16)sizeof(tGATTS_RSP));
+    BT_HDR          *p_buf = (BT_HDR *)osi_malloc(sizeof(tGATTS_RSP));
     UINT8           *p;
     BOOLEAN         is_overflow = FALSE;
 
@@ -148,7 +148,7 @@
         if (fixed_queue_length(p_cmd->multi_rsp_q) == p_cmd->multi_req.num_handles)
         {
             len = sizeof(BT_HDR) + L2CAP_MIN_OFFSET + mtu;
-            if ((p_buf = (BT_HDR *)osi_getbuf(len)) == NULL)
+            if ((p_buf = (BT_HDR *)osi_malloc(len)) == NULL)
             {
                 p_cmd->status = GATT_INSUF_RESOURCE;
                 return(TRUE);
@@ -228,12 +228,12 @@
             {
                 GATT_TRACE_ERROR("process_read_multi_rsp - nothing found!!");
                 p_cmd->status = GATT_NOT_FOUND;
-                osi_freebuf(p_buf);
-                GATT_TRACE_DEBUG("osi_freebuf(p_buf)");
+                osi_free(p_buf);
+                GATT_TRACE_DEBUG("osi_free(p_buf)");
             }
             else if (p_cmd->p_rsp_msg != NULL)
             {
-                osi_freebuf(p_buf);
+                osi_free(p_buf);
             }
             else
             {
@@ -471,7 +471,7 @@
 
             for (ll = 0; ll < p_tcb->sr_cmd.multi_req.num_handles; ll ++)
             {
-                if ((p_msg = (tGATTS_RSP *)osi_getbuf(sizeof(tGATTS_RSP))) != NULL)
+                if ((p_msg = (tGATTS_RSP *)osi_malloc(sizeof(tGATTS_RSP))) != NULL)
                 {
                     memset(p_msg, 0, sizeof(tGATTS_RSP))
                     ;
@@ -496,7 +496,7 @@
                         gatt_sr_process_app_rsp(p_tcb, gatt_cb.sr_reg[i_rcb].gatt_if ,trans_id, op_code, GATT_SUCCESS, p_msg);
                     }
                     /* either not using or done using the buffer, release it now */
-                    osi_freebuf(p_msg);
+                    osi_free(p_msg);
                 }
                 else
                 {
@@ -786,7 +786,7 @@
 
             if (reason == GATT_SUCCESS)
             {
-                if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
+                if ((p_msg =  (BT_HDR *)osi_malloc(msg_len)) == NULL)
                 {
                     GATT_TRACE_ERROR("gatts_process_primary_service_req failed. no resources.");
                     reason = GATT_NO_RESOURCES;
@@ -816,7 +816,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        osi_freebuf(p_msg);
+        osi_free(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -849,7 +849,7 @@
     {
         buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
 
-        if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_malloc(buf_len)) == NULL)
         {
             reason = GATT_NO_RESOURCES;
         }
@@ -891,7 +891,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        osi_freebuf(p_msg);
+        osi_free(p_msg);
         gatt_send_error_rsp (p_tcb, reason, op_code, s_hdl, FALSE);
     }
     else
@@ -981,9 +981,8 @@
 {
     tBT_UUID            uuid;
     tGATT_SR_REG        *p_rcb;
-    UINT16              msg_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET),
-                                  buf_len,
-                                  s_hdl, e_hdl, err_hdl = 0;
+    size_t              msg_len = sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET;
+    UINT16              buf_len, s_hdl, e_hdl, err_hdl = 0;
     BT_HDR              *p_msg = NULL;
     tGATT_STATUS        reason, ret;
     UINT8               *p;
@@ -1006,7 +1005,7 @@
 
     if (reason == GATT_SUCCESS)
     {
-        if ((p_msg =  (BT_HDR *)osi_getbuf(msg_len)) == NULL)
+        if ((p_msg =  (BT_HDR *)osi_malloc(msg_len)) == NULL)
         {
             GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1072,7 +1071,7 @@
     }
     if (reason != GATT_SUCCESS)
     {
-        osi_freebuf(p_msg);
+        osi_free(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1188,14 +1187,14 @@
 static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8 op_code,
                                    UINT16 handle, UINT16 len, UINT8 *p_data)
 {
-    UINT16          buf_len = (UINT16)(sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET);
+    size_t          buf_len = sizeof(BT_HDR) + p_tcb->payload_size + L2CAP_MIN_OFFSET;
     tGATT_STATUS    reason;
     BT_HDR          *p_msg = NULL;
     UINT8           sec_flag, key_size, *p;
     UINT16          offset = 0, value_len = 0;
 
     UNUSED (len);
-    if ((p_msg =  (BT_HDR *)osi_getbuf(buf_len)) == NULL)
+    if ((p_msg =  (BT_HDR *)osi_malloc(buf_len)) == NULL)
     {
         GATT_TRACE_ERROR("gatts_process_find_info failed. no resources.");
 
@@ -1224,7 +1223,7 @@
                                                  offset,
                                                  p,
                                                  &value_len,
-                                                 buf_len,
+                                                 (uint16_t)buf_len,
                                                  sec_flag,
                                                  key_size,
                                                  0);
@@ -1234,7 +1233,7 @@
 
     if (reason != GATT_SUCCESS)
     {
-        osi_freebuf(p_msg);
+        osi_free(p_msg);
 
         /* in theroy BUSY is not possible(should already been checked), protected check */
         if (reason != GATT_PENDING && reason != GATT_BUSY)
@@ -1376,7 +1375,7 @@
                                     p_buf->handle,
                                     p_buf->len,
                                     p_buf->value);
-        osi_freebuf(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
+        osi_free(fixed_queue_try_remove_from_queue(p_tcb->pending_ind_q,
                                                       p_buf));
     }
 }