Add casts and consts to ease user conversion to C++.

You would still need to run zlib2ansi on all of the *.c files.
This commit is contained in:
Mark Adler
2013-03-24 15:18:02 -07:00
parent 0aac8cf7c4
commit e9f0b78443
6 changed files with 17 additions and 16 deletions

13
gzlib.c
View File

@@ -108,7 +108,7 @@ local gzFile gz_open(path, fd, mode)
return NULL;
/* allocate gzFile structure to return */
state = malloc(sizeof(gz_state));
state = (gz_statep)malloc(sizeof(gz_state));
if (state == NULL)
return NULL;
state->size = 0; /* no buffers allocated yet */
@@ -196,8 +196,8 @@ local gzFile gz_open(path, fd, mode)
}
else
#endif
len = strlen(path);
state->path = malloc(len + 1);
len = strlen((const char *)path);
state->path = (char *)malloc(len + 1);
if (state->path == NULL) {
free(state);
return NULL;
@@ -242,7 +242,7 @@ local gzFile gz_open(path, fd, mode)
#ifdef _WIN32
fd == -2 ? _wopen(path, oflag, 0666) :
#endif
open(path, oflag, 0666));
open((const char *)path, oflag, 0666));
if (state->fd == -1) {
free(state->path);
free(state);
@@ -288,7 +288,7 @@ gzFile ZEXPORT gzdopen(fd, mode)
char *path; /* identifier for error messages */
gzFile gz;
if (fd == -1 || (path = malloc(7 + 3 * sizeof(int))) == NULL)
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
return NULL;
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
@@ -598,7 +598,8 @@ void ZLIB_INTERNAL gz_error(state, err, msg)
return;
/* construct error message with path */
if ((state->msg = malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
NULL) {
state->err = Z_MEM_ERROR;
return;
}