Browse Source

fix memory problems occured with latest changes

master
Georg Hopp 14 years ago
parent
commit
dfcbc4946c
  1. 4
      include/server.h
  2. 2
      include/socket.h
  3. 6
      src/http/header.c
  4. 7
      src/http/header/add.c
  5. 2
      src/http/response/me.c
  6. 2
      src/server/poll.c
  7. 2
      src/server/read.c
  8. 4
      src/testserver.c
  9. 4
      src/utils/daemonize.c

4
include/server.h

@ -26,8 +26,8 @@
#ifndef __SERVER_H__
#define __SERVER_H__
#include <stdio.h> /* for printf() and fprintf() */
#include <poll.h> /* for select system call and related */
#include <stdio.h> // for printf() and fprintf()
#include <poll.h> // for poll system call and related
#include "class.h"
#include "socket.h"

2
include/socket.h

@ -25,7 +25,7 @@
#ifndef __SOCKET_H__
#define __SOCKET_H__
#include <arpa/inet.h> /* for in_port_t */
#include <arpa/inet.h> // for in_port_t
#include "class.h"
#include "logger.h"

6
src/http/header.c

@ -46,9 +46,9 @@ ctor(void * _this, va_list * params) {
this->hash = sdbm((unsigned char *)name);
this->value = malloc(sizeof(char*) * (++this->nvalue));
this->value[this->nvalue - 1] = malloc(strlen(value) + 1);
strcpy(this->value[this->nvalue - 1], value);
this->value = malloc(sizeof(char*) * (++(this->nvalue)));
(this->value)[this->nvalue - 1] = malloc(strlen(value) + 1);
strcpy((this->value)[this->nvalue - 1], value);
return 0;
}

7
src/http/header/add.c

@ -46,8 +46,11 @@ httpHeaderAdd(const HttpHeader * root, HttpHeader header)
HttpHeader * found = tsearch(header, (void **)root, comp);
if (*found != header) {
(*found)->value = realloc((*found)->value, sizeof(char) * (++(*found)->nvalue));
(*found)->value[(*found)->nvalue - 1] = malloc(strlen(header->value) + 1);
(*found)->value = realloc(
(*found)->value,
sizeof(char*) * (++(*found)->nvalue));
(*found)->value[(*found)->nvalue - 1] = malloc(
strlen((header->value)[0]) + 1);
strcpy(((*found)->value)[(*found)->nvalue - 1], (header->value)[0]);
delete(&header);
}

2
src/http/response/me.c

@ -76,7 +76,7 @@ httpResponseMe(int value)
new(HttpHeader, "Set-Cookie", "profession=\"coder\""));
message->type = HTTP_MESSAGE_BUFFERED;
message->nbody = sizeof(RESP_DATA) - 1;
message->nbody = sizeof(RESP_DATA)-1-2;
message->body = calloc(1, sizeof(RESP_DATA)-2);
sprintf(message->body, RESP_DATA, value);

2
src/server/poll.c

@ -67,7 +67,7 @@ serverPoll(Server this) {
case EINVAL:
case ENOMEM:
doShutdown = 1;
/* Fallthrough */
// DROP THROUGH
case EINTR:
loggerLog(this->logger, LOGGER_CRIT,

2
src/server/read.c

@ -47,7 +47,7 @@ serverRead(Server this, unsigned int i)
* \todo make sure all pending writes will be done before
* close.
*/
/* DROP-THROUGH */
// DROP-THROUGH
case -1:
/*

4
src/testserver.c

@ -88,12 +88,12 @@ main()
close(shm);
/* Block SIGALRM */
// Block SIGALRM
sigemptyset(&block_these);
sigaddset(&block_these, SIGALRM);
sigprocmask(SIG_BLOCK, &block_these, &pause_mask);
/* Set up handler for SIGALRM */
// Set up handler for SIGALRM
sigemptyset(&s.sa_mask);
sigaddset(&s.sa_mask, SIGINT);
s.sa_flags = 0;

4
src/utils/daemonize.c

@ -22,8 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h> /* for printf() and fprintf() */
#include <unistd.h> /* for getopt */
#include <stdio.h> // for printf() and fprintf()
#include <unistd.h> // for getopt
#include <stdlib.h>

Loading…
Cancel
Save