pkwrite.c: call calloc and free properly

Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/library/pkwrite.c b/library/pkwrite.c
index 8bbd40e..f0dc718 100644
--- a/library/pkwrite.c
+++ b/library/pkwrite.c
@@ -572,7 +572,7 @@
 {
     int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
     unsigned char *output_buf = NULL;
-    output_buf = calloc(1, PUB_DER_MAX_BYTES);
+    output_buf = mbedtls_calloc(1, PUB_DER_MAX_BYTES);
     if (output_buf == NULL) {
         return MBEDTLS_ERR_PK_ALLOC_FAILED;
     }
@@ -594,7 +594,7 @@
 
     ret = 0;
 cleanup:
-    free(output_buf);
+    mbedtls_free(output_buf);
     return ret;
 }
 
@@ -602,7 +602,7 @@
 {
     int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
     unsigned char *output_buf = NULL;
-    output_buf = calloc(1, PRV_DER_MAX_BYTES);
+    output_buf = mbedtls_calloc(1, PRV_DER_MAX_BYTES);
     if (output_buf == NULL) {
         return MBEDTLS_ERR_PK_ALLOC_FAILED;
     }
@@ -641,7 +641,7 @@
 
     ret = 0;
 cleanup:
-    free(output_buf);
+    mbedtls_free(output_buf);
     return ret;
 }
 #endif /* MBEDTLS_PEM_WRITE_C */