summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylwester Nawrocki <s.nawrocki@samsung.com>2017-11-27 12:26:33 +0100
committerSylwester Nawrocki <s.nawrocki@samsung.com>2017-11-27 15:50:13 +0100
commitdde31ebb936c733f4185cd215b6ba96c980afeec (patch)
treebbcbce5fdebabfd52784f0fe97818443aa6b0fba
parent33a4d4bdae7209e76c75d618239f92fe5639e8e2 (diff)
downloadgst-plugins-camera-n4-dde31ebb936c733f4185cd215b6ba96c980afeec.tar.gz
gst-plugins-camera-n4-dde31ebb936c733f4185cd215b6ba96c980afeec.tar.bz2
gst-plugins-camera-n4-dde31ebb936c733f4185cd215b6ba96c980afeec.zip
Replace malloc() + memset() with calloc()
Also unneeded casting from void * is removed. Change-Id: I462ea5b5f42be44c59f956bbd2c4f0ebc78ffc27 Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
-rw-r--r--camerasrc/src/camerasrc.c7
-rw-r--r--camerasrc/src/gstcamerasrc.c8
2 files changed, 4 insertions, 11 deletions
diff --git a/camerasrc/src/camerasrc.c b/camerasrc/src/camerasrc.c
index 2bee78b..9003d0e 100644
--- a/camerasrc/src/camerasrc.c
+++ b/camerasrc/src/camerasrc.c
@@ -1769,21 +1769,18 @@ int camerasrc_create(camsrc_handle_t *phandle)
return CAMERASRC_ERR_NULL_POINTER;
}
- p = (camerasrc_handle_t *)malloc(sizeof(camerasrc_handle_t));
+ p = calloc(1, sizeof(camerasrc_handle_t));
if(p == NULL) {
camsrc_error("malloc fail");
return CAMERASRC_ERR_ALLOCATION;
}
- memset(p, '\0', sizeof(camerasrc_handle_t));
-
- /* STATE TO MEANINGFUL STATE */
+ /* Set to a meaningful state */
p->cur_state = CAMERASRC_STATE_NONE;
CAMERASRC_SET_STATE(p, CAMERASRC_STATE_CREATED);
CAMERASRC_SET_PHASE(p, CAMERASRC_PHASE_NON_RUNNING);
camsrc_info("Transit to non-running phase");
- /* INIT VARIABLES */
err = _camerasrc_initialize_handle(p);
if(err != CAMERASRC_SUCCESS) {
camsrc_error("Invalid handle");
diff --git a/camerasrc/src/gstcamerasrc.c b/camerasrc/src/gstcamerasrc.c
index 07914ad..8e3a67a 100644
--- a/camerasrc/src/gstcamerasrc.c
+++ b/camerasrc/src/gstcamerasrc.c
@@ -1774,10 +1774,8 @@ static void gst_camerasrc_buffer_finalize(GstCameraBuffer *buffer)
camerasrc->create_jpeg == TRUE &&
(camerasrc->cap_count_reverse > 0 && camerasrc->cap_next_time <= cur_time) ) {
- capture_data = (camerasrc_capture_data_info *)malloc(sizeof(camerasrc_capture_data_info));
+ capture_data = calloc(1, sizeof(camerasrc_capture_data_info));
if (capture_data) {
- memset(capture_data, 0x0, sizeof(camerasrc_capture_data_info));
-
capture_data->buffer_index = index;
capture_data->make_thumbnail = TRUE;
capture_data->flash_activated = camerasrc->flash_activated;
@@ -2138,14 +2136,12 @@ static GstMemory *gst_camerasrc_get_zero_copy_data(GstCameraSrc *camerasrc, guin
/*GST_LOG_OBJECT (camerasrc, "index[%d],pix_format[%x]", index, camerasrc->fourcc);*/
- mm_buf = (MMVideoBuffer *)malloc(sizeof(MMVideoBuffer));
+ mm_buf = calloc(1, sizeof(MMVideoBuffer));
if (mm_buf == NULL) {
GST_ERROR_OBJECT(camerasrc, "failed to alloc MMVideoBuffer");
return NULL;
}
- memset(mm_buf, 0x0, sizeof(MMVideoBuffer));
-
mm_buf->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
/*
* FIXME: The number of planes should depend on fourcc, now this function