[IOT-1783] Fix output buffer size
1. Don't allocate securityPayloadSize and use INIT_SIZE as the buffer
size parameter, when calling OCConvertPayloadHelper.
2. Using Realloc here was wasteful, because Realloc copies the
current buffer contents in the new, larger buffer. The current
buffer contents are not needed in the larger buffer.
3. Call OCConvertPayloadHelper in a single place instead of three.
Change-Id: Ib854d91c5938df10597207f4aa88945dd8720cf5
Signed-off-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16859
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Mike Fenelon <mike.fenelon@microsoft.com>
Reviewed-by: Habib Virji <habib.virji@samsung.com>