aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-08 01:38:29 +0200
committerGravatar Nicolas "Pixel" Noble <pixel@nobis-crew.org>2016-04-08 01:38:29 +0200
commitb29d8cfeb886e951dcbacc0f42f12624a2684086 (patch)
tree52196737d627b9b755ed3d93715b7681b2627b15 /src/core/lib
parentbdf80ac31f407d7886acd6a0fe2fb1ab4c43c6c9 (diff)
Last few mallocs / frees.
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/support/log_linux.c1
-rw-r--r--src/core/lib/tsi/fake_transport_security.c3
-rw-r--r--src/core/lib/tsi/ssl_transport_security.c1
-rw-r--r--src/core/lib/tsi/transport_security.c24
4 files changed, 11 insertions, 18 deletions
diff --git a/src/core/lib/support/log_linux.c b/src/core/lib/support/log_linux.c
index 6d4b63bbe0..ff3febb38e 100644
--- a/src/core/lib/support/log_linux.c
+++ b/src/core/lib/support/log_linux.c
@@ -68,6 +68,7 @@ void gpr_log(const char *file, int line, gpr_log_severity severity,
}
va_end(args);
gpr_log_message(file, line, severity, message);
+ /* message has been allocated by vasprintf above, and needs free */
free(message);
}
diff --git a/src/core/lib/tsi/fake_transport_security.c b/src/core/lib/tsi/fake_transport_security.c
index a0f69c3d64..0e20d6fd71 100644
--- a/src/core/lib/tsi/fake_transport_security.c
+++ b/src/core/lib/tsi/fake_transport_security.c
@@ -36,6 +36,7 @@
#include <stdlib.h>
#include <string.h>
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
#include <grpc/support/useful.h>
@@ -137,7 +138,7 @@ static int tsi_fake_frame_ensure_size(tsi_fake_frame *frame) {
frame->data = gpr_malloc(frame->allocated_size);
if (frame->data == NULL) return 0;
} else if (frame->size > frame->allocated_size) {
- unsigned char *new_data = realloc(frame->data, frame->size);
+ unsigned char *new_data = gpr_realloc(frame->data, frame->size);
if (new_data == NULL) {
gpr_free(frame->data);
frame->data = NULL;
diff --git a/src/core/lib/tsi/ssl_transport_security.c b/src/core/lib/tsi/ssl_transport_security.c
index ef3aeb7090..045901cc72 100644
--- a/src/core/lib/tsi/ssl_transport_security.c
+++ b/src/core/lib/tsi/ssl_transport_security.c
@@ -45,6 +45,7 @@
#include <arpa/inet.h>
#endif
+#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
diff --git a/src/core/lib/tsi/transport_security.c b/src/core/lib/tsi/transport_security.c
index 66f1e356d6..830cf09584 100644
--- a/src/core/lib/tsi/transport_security.c
+++ b/src/core/lib/tsi/transport_security.c
@@ -33,6 +33,9 @@
#include "src/core/lib/tsi/transport_security.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/string_util.h>
+
#include <stdlib.h>
#include <string.h>
@@ -40,19 +43,6 @@
int tsi_tracing_enabled = 0;
-/* --- Utils. --- */
-
-char *tsi_strdup(const char *src) {
- char *dst;
- size_t len;
- if (!src) return NULL;
- len = strlen(src) + 1;
- dst = malloc(len);
- if (!dst) return NULL;
- memcpy(dst, src, len);
- return dst;
-}
-
/* --- tsi_result common implementation. --- */
const char *tsi_result_to_string(tsi_result result) {
@@ -214,15 +204,15 @@ static void tsi_peer_destroy_list_property(tsi_peer_property *children,
for (i = 0; i < child_count; i++) {
tsi_peer_property_destruct(&children[i]);
}
- free(children);
+ gpr_free(children);
}
void tsi_peer_property_destruct(tsi_peer_property *property) {
if (property->name != NULL) {
- free(property->name);
+ gpr_free(property->name);
}
if (property->value.data != NULL) {
- free(property->value.data);
+ gpr_free(property->value.data);
}
*property = tsi_init_peer_property(); /* Reset everything to 0. */
}
@@ -242,7 +232,7 @@ tsi_result tsi_construct_allocated_string_peer_property(
if (name != NULL) property->name = gpr_strdup(name);
if (value_length > 0) {
property->value.data = gpr_malloc(value_length);
- memset(value.data, 0, value_length);
+ memset(property->value.data, 0, value_length);
property->value.length = value_length;
}
return TSI_OK;