Compiler warning fix for memory macro's. Small layout changes.

remotes/origin/master-1.0.x
Victor Julien 15 years ago
parent 06a65cb460
commit bc55fb27dc

@ -183,27 +183,23 @@ void HTPStateFree(void *state)
s->flags &=~ HTP_FLAG_NEW_BODY_SET; s->flags &=~ HTP_FLAG_NEW_BODY_SET;
/* free the connection parser memory used by HTP library */ /* free the connection parser memory used by HTP library */
if (s != NULL) { if (s != NULL && s->connp != NULL) {
if (s->connp != NULL) { size_t i;
size_t i; /* free the list of body chunks */
/* free the list of body chunks */ if (s->connp->conn != NULL) {
if (s->connp->conn != NULL) { for (i = 0; i < list_size(s->connp->conn->transactions); i++) {
for (i = 0; i < list_size(s->connp->conn->transactions); i++) { htp_tx_t *tx = (htp_tx_t *)list_get(s->connp->conn->transactions, i);
htp_tx_t *tx = (htp_tx_t *)list_get(s->connp->conn->transactions, i); if (tx != NULL) {
if (tx != NULL) { SCHtpTxUserData *htud = (SCHtpTxUserData *) htp_tx_get_user_data(tx);
if (htud != NULL) {
SCHtpTxUserData *htud = (SCHtpTxUserData *) htp_tx_get_user_data(tx); HtpBodyFree(&htud->body);
if (htud != NULL) { SCFree(htud);
HtpBodyFree(&htud->body);
SCFree(htud);
}
htp_tx_set_user_data(tx, NULL);
} }
htp_tx_set_user_data(tx, NULL);
} }
} }
htp_connp_destroy_all(s->connp);
} }
htp_connp_destroy_all(s->connp);
} }
SCFree(s); SCFree(s);
@ -263,6 +259,7 @@ void HTPStateTransactionFree(void *state, uint16_t id) {
/** /**
* \brief Sets a flag that informs the HTP app layer that some module in the * \brief Sets a flag that informs the HTP app layer that some module in the
* engine needs the http request body data. * engine needs the http request body data.
* \initonly
*/ */
void AppLayerHtpEnableRequestBodyCallback(void) void AppLayerHtpEnableRequestBodyCallback(void)
{ {

@ -52,7 +52,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = malloc(a); \ ptrmem = malloc(a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -61,8 +61,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
\ \
global_mem += a; \ global_mem += a; \
if (print_mem_flag == 1) \ if (print_mem_flag == 1) \
SCLogInfo("SCMalloc return at %p of size %"PRIdMAX, \ SCLogInfo("SCMalloc return at %p of size %"PRIuMAX, \
ptrmem, (size_t)a); \ ptrmem, (uintmax_t)a); \
\ \
(void*)ptrmem; \ (void*)ptrmem; \
}) })
@ -75,7 +75,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = realloc(x, a); \ ptrmem = realloc(x, a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -84,8 +84,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
\ \
global_mem += a; \ global_mem += a; \
if (print_mem_flag == 1) \ if (print_mem_flag == 1) \
SCLogInfo("SCRealloc return at %p (old:%p) of size %"PRIdMAX, \ SCLogInfo("SCRealloc return at %p (old:%p) of size %"PRIuMAX, \
ptrmem, x, (size_t)a); \ ptrmem, x, (uintmax_t)a); \
\ \
(void*)ptrmem; \ (void*)ptrmem; \
}) })
@ -98,7 +98,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = calloc(nm, a); \ ptrmem = calloc(nm, a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -107,8 +107,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
\ \
global_mem += a*nm; \ global_mem += a*nm; \
if (print_mem_flag == 1) \ if (print_mem_flag == 1) \
SCLogInfo("SCCalloc return at %p of size %Zu nm %"PRIdMAX, \ SCLogInfo("SCCalloc return at %p of size %"PRIuMAX" nm %"PRIuMAX, \
ptrmem, (size_t)a, (size_t)nm); \ ptrmem, (uintmax_t)a, (uintmax_t)nm); \
\ \
(void*)ptrmem; \ (void*)ptrmem; \
}) })
@ -122,7 +122,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
if (ptrmem == NULL) { \ if (ptrmem == NULL) { \
size_t len = strlen(a); \ size_t len = strlen(a); \
SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (size_t)len); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -131,8 +131,8 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
\ \
global_mem += len; \ global_mem += len; \
if (print_mem_flag == 1) \ if (print_mem_flag == 1) \
SCLogInfo("SCStrdup return at %p of size %"PRIdMAX, \ SCLogInfo("SCStrdup return at %p of size %"PRIuMAX, \
ptrmem, (size_t)len); \ ptrmem, (uintmax_t)len); \
\ \
(void*)ptrmem; \ (void*)ptrmem; \
}) })
@ -160,7 +160,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = malloc(a); \ ptrmem = malloc(a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCMalloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -175,7 +175,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = realloc(x, a); \ ptrmem = realloc(x, a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCRealloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -190,7 +190,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
ptrmem = calloc(nm, a); \ ptrmem = calloc(nm, a); \
if (ptrmem == NULL && a > 0) { \ if (ptrmem == NULL && a > 0) { \
SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCCalloc failed: %s, while trying " \
"to allocate %Zu bytes", strerror(errno), (size_t)a); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)a); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \
@ -206,7 +206,7 @@ SC_ATOMIC_EXTERN(unsigned int, engine_stage);
if (ptrmem == NULL) { \ if (ptrmem == NULL) { \
size_t len = strlen(a); \ size_t len = strlen(a); \
SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \ SCLogError(SC_ERR_MEM_ALLOC, "SCStrdup failed: %s, while trying " \
"to allocate %"PRIuMAX" bytes", strerror(errno), (size_t)len); \ "to allocate %"PRIuMAX" bytes", strerror(errno), (uintmax_t)len); \
if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\ if (SC_ATOMIC_GET(engine_stage) == SURICATA_INIT) {\
SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \ SCLogError(SC_ERR_FATAL, "Out of memory. The engine cannot be initialized. Exiting..."); \
exit(EXIT_FAILURE); \ exit(EXIT_FAILURE); \

Loading…
Cancel
Save