Skip to content

Commit

Permalink
[DEBUG] Some code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
BoubacarDiene committed Mar 16, 2018
1 parent 4096953 commit aaef2dd
Show file tree
Hide file tree
Showing 30 changed files with 62 additions and 271 deletions.
7 changes: 7 additions & 0 deletions inc/network/LinkHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ enum link_mode_e;
enum state_e;
enum stream_type_e;

struct recipient_s;
struct custom_header_s;
struct custom_content_s;
struct http_get_s;
Expand Down Expand Up @@ -171,6 +172,12 @@ enum stream_type_e {
STREAM_TYPE_MAX
};

struct recipient_s {
char host[MAX_ADDRESS_SIZE];
char service[MIN_STR_SIZE];
char path[MAX_PATH_SIZE];
};

struct custom_header_s {
char str[MAX_HEADER_SIZE];
};
Expand Down
13 changes: 0 additions & 13 deletions inc/utils/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ extern "C" {

#include <assert.h>
#include <errno.h>
#include <math.h>
#include <semaphore.h>
#include <stdint.h>
#include <stdio.h>
Expand Down Expand Up @@ -79,23 +78,11 @@ enum priority_e {
PRIORITY_HIGHEST
};

enum pipe_e {
PIPE_READ,
PIPE_WRITE,
PIPE_COUNT
};

struct buffer_s {
void *data;
ssize_t length;
};

struct recipient_s {
char host[MAX_ADDRESS_SIZE];
char service[MIN_STR_SIZE];
char path[MAX_PATH_SIZE];
};

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 8 additions & 1 deletion inc/video/V4l2.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern "C" {
/* -------------------------------------------------------------------------------------------- */

enum v4l2_error_e;
enum v4l2_pipe_e;

struct v4l2_open_device_params_s;
struct v4l2_configure_device_params_s;
Expand Down Expand Up @@ -94,6 +95,12 @@ enum v4l2_error_e {
V4L2_ERROR_BAD_CAPS
};

enum v4l2_pipe_e {
V4L2_PIPE_READ,
V4L2_PIPE_WRITE,
V4L2_PIPE_COUNT
};

struct v4l2_open_device_params_s {
char path[MAX_PATH_SIZE];
uint32_t caps;
Expand Down Expand Up @@ -153,7 +160,7 @@ struct v4l2_s {

char path[MAX_PATH_SIZE];
int32_t deviceFd;
int32_t quitFd[PIPE_COUNT];
int32_t quitFd[V4L2_PIPE_COUNT];

struct v4l2_capability caps;
struct v4l2_format format;
Expand Down
18 changes: 0 additions & 18 deletions src/Main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ static void setPriority(struct options_s *in);
/* /////////////////////////////////////////// MAIN /////////////////////////////////////////// */
/* -------------------------------------------------------------------------------------------- */

/*!
* main() function
*/
int main(int argc, char **argv)
{
int32_t ret = EXIT_FAILURE;
Expand Down Expand Up @@ -519,68 +516,55 @@ int main(int argc, char **argv)
parserParseExit:
if (input->appDataDir) {
free(input->appDataDir);
input->appDataDir = NULL;
}

if (input->resRootDir) {
free(input->resRootDir);
input->resRootDir = NULL;
}

if (input->libRootDir) {
free(input->libRootDir);
input->libRootDir = NULL;
}

uint8_t count;
while (input->nbCtrlLibs > 0) {
count = input->nbCtrlLibs - 1;
if (input->ctrlLibs[count].path) {
free(input->ctrlLibs[count].path);
input->ctrlLibs[count].path = NULL;
}
if (input->ctrlLibs[count].initFn) {
free(input->ctrlLibs[count].initFn);
input->ctrlLibs[count].initFn = NULL;
}
if (input->ctrlLibs[count].uninitFn) {
free(input->ctrlLibs[count].uninitFn);
input->ctrlLibs[count].uninitFn = NULL;
}
if (input->ctrlLibs[count].onCommandCb) {
free(input->ctrlLibs[count].onCommandCb);
input->ctrlLibs[count].onCommandCb = NULL;
}
if (input->ctrlLibs[count].onEventCb) {
free(input->ctrlLibs[count].onEventCb);
input->ctrlLibs[count].onEventCb = NULL;
}
--input->nbCtrlLibs;
}

if (input->ctrlLibs) {
free(input->ctrlLibs);
input->ctrlLibs = NULL;
}

if (input->clientsConfig.xml) {
free(input->clientsConfig.xml);
input->clientsConfig.xml = NULL;
}

if (input->serversConfig.xml) {
free(input->serversConfig.xml);
input->serversConfig.xml = NULL;
}

if (input->videosConfig.xml) {
free(input->videosConfig.xml);
input->videosConfig.xml = NULL;
}

if (input->graphicsConfig.xml) {
free(input->graphicsConfig.xml);
input->graphicsConfig.xml = NULL;
}

if (mCtx->parserObj) {
Expand All @@ -590,7 +574,6 @@ int main(int argc, char **argv)

parserInitExit:
free(mCtx);
mCtx = NULL;

return ret;
}
Expand Down Expand Up @@ -782,7 +765,6 @@ static void onItemCb(void *userData, const char **attrs)
snprintf(ctrlLib->path, len, "%s/%s", input->libRootDir, temp);

free(temp);
temp = NULL;
}

Logd("Control library - path : \"%s\" / \
Expand Down
13 changes: 1 addition & 12 deletions src/control/Control.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ enum control_error_e Control_Init(struct control_s **obj, struct context_s *ctx)

lockExit:
free(pData);
pData = NULL;

free(*obj);
*obj = NULL;

Expand All @@ -229,11 +227,7 @@ enum control_error_e Control_UnInit(struct control_s **obj)

(void)pthread_mutex_destroy(&pData->lock);

pData->ctx = NULL;

free((*obj)->pData);
(*obj)->pData = NULL;

free(pData);
free(*obj);
*obj = NULL;

Expand Down Expand Up @@ -267,9 +261,7 @@ enum control_error_e uninitElementData_f(struct control_s *obj, void **data)
assert(obj && data && *data);

struct control_element_data_s *elementData = (struct control_element_data_s*)(*data);

free(elementData);
elementData = NULL;

return CONTROL_ERROR_NONE;
}
Expand Down Expand Up @@ -393,13 +385,10 @@ enum control_error_e unsetCommandHandlers_f(struct control_s *obj, void *data)
for (i = 0; i < elementData->nbCommandHandlers; i++) {
if ((elementData->commandHandlers[i]).name) {
free((elementData->commandHandlers[i]).name);
(elementData->commandHandlers[i]).name = NULL;
}
if ((elementData->commandHandlers[i]).data) {
free((elementData->commandHandlers[i]).data);
(elementData->commandHandlers[i]).data = NULL;
}
(elementData->commandHandlers[i]).fct = NULL;
}

if (elementData->commandHandlers) {
Expand Down
12 changes: 4 additions & 8 deletions src/control/controllers/Commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ enum controllers_error_e uninitCmdsTask_f(struct controllers_s *obj);
enum controllers_error_e startCmdsTask_f(struct controllers_s *obj);
enum controllers_error_e stopCmdsTask_f(struct controllers_s *obj);

void sendToEngine_f(void *userData, struct controller_command_s *command,
void sendToEngine_f(void *enginePrivateData, struct controller_command_s *command,
controllers_command_action_done_cb actionDoneCb);

/* -------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -234,12 +234,12 @@ enum controllers_error_e stopCmdsTask_f(struct controllers_s *obj)
/*!
*+
*/
void sendToEngine_f(void *userData, struct controller_command_s *command,
void sendToEngine_f(void *enginePrivateData, struct controller_command_s *command,
controllers_command_action_done_cb actionDoneCb)
{
assert(userData && command);
assert(enginePrivateData && command);

struct controllers_lib_s *lib = (struct controllers_lib_s*)userData;
struct controllers_lib_s *lib = (struct controllers_lib_s*)enginePrivateData;
struct controllers_s *controllersObj = (struct controllers_s*)(lib->pData);
struct controllers_task_s *cmdsTask = &controllersObj->tasksMngt[CONTROLLERS_TASK_CMDS].task;
struct list_s *cmdsList = cmdsTask->list;
Expand Down Expand Up @@ -347,9 +347,5 @@ static void releaseCb(struct list_s *obj, void *element)
elementToRemove->actionDoneCb(elementToRemove->command);
}

elementToRemove->command = NULL;
elementToRemove->actionDoneCb = NULL;

free(elementToRemove);
elementToRemove = NULL;
}
4 changes: 0 additions & 4 deletions src/control/controllers/Controllers.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ enum controllers_error_e Controllers_UnInit(struct controllers_s **obj)
{
assert(obj && *obj);

(*obj)->params.ctx = NULL;
(*obj)->params.onCommandCb = NULL;
(*obj)->params.userData = NULL;

free(*obj);
*obj = NULL;

Expand Down
18 changes: 8 additions & 10 deletions src/control/controllers/Events.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ enum controllers_error_e stopEvtsTask_f(struct controllers_s *obj);

enum controllers_error_e notify_f(struct controllers_s *obj, struct controller_event_s *event);

void registerEvents_f(void *userData, int32_t eventsMask);
void unregisterEvents_f(void *userData, int32_t eventsMask);
void registerEvents_f(void *enginePrivateData, int32_t eventsMask);
void unregisterEvents_f(void *enginePrivateData, int32_t eventsMask);

/* -------------------------------------------------------------------------------------------- */
/* /////////////////////////////// PRIVATE FUNCTIONS PROTOTYPES /////////////////////////////// */
Expand Down Expand Up @@ -286,11 +286,11 @@ enum controllers_error_e notify_f(struct controllers_s *obj, struct controller_e
/*!
*
*/
void registerEvents_f(void *userData, int32_t eventsMask)
void registerEvents_f(void *enginePrivateData, int32_t eventsMask)
{
assert(userData);
assert(enginePrivateData);

struct controllers_lib_s *lib = (struct controllers_lib_s*)userData;
struct controllers_lib_s *lib = (struct controllers_lib_s*)enginePrivateData;
struct controllers_s *controllersObj = (struct controllers_s*)(lib->pData);
struct controllers_task_s *evtsTask = &controllersObj->tasksMngt[CONTROLLERS_TASK_EVTS].task;

Expand All @@ -309,11 +309,11 @@ void registerEvents_f(void *userData, int32_t eventsMask)
/*!
*
*/
void unregisterEvents_f(void *userData, int32_t eventsMask)
void unregisterEvents_f(void *enginePrivateData, int32_t eventsMask)
{
assert(userData);
assert(enginePrivateData);

struct controllers_lib_s *lib = (struct controllers_lib_s*)userData;
struct controllers_lib_s *lib = (struct controllers_lib_s*)enginePrivateData;
struct controllers_s *controllersObj = (struct controllers_s*)(lib->pData);
struct controllers_task_s *evtsTask = &controllersObj->tasksMngt[CONTROLLERS_TASK_EVTS].task;

Expand Down Expand Up @@ -419,9 +419,7 @@ static void releaseCb(struct list_s *obj, void *element)

if (event->name) {
free(event->name);
event->name = NULL;
}

free(elementToRemove);
elementToRemove = NULL;
}
Loading

0 comments on commit aaef2dd

Please sign in to comment.