Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/libsam3/libsam3.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,10 @@ __attribute__((format(printf, 2, 3))) int sam3tcpPrintf(int fd, const char *fmt,
else
size *= 2;
if (p == buf) {
if ((p = malloc(size + 4)) == NULL)
if ((p = (char*)malloc(size + 4)) == NULL)
return -1;
} else {
if ((np = realloc(p, size + 4)) == NULL) {
if ((np = (char*)realloc(p, size + 4)) == NULL) {
free(p);
return -1;
}
Expand Down Expand Up @@ -426,7 +426,7 @@ const char *sam3FindField(const SAMFieldList *list, const char *field) {

static char *xstrdup(const char *s, int len) {
if (len >= 0) {
char *res = malloc(len + 1);
char *res = (char*)malloc(len + 1);
//
if (res != NULL) {
if (len > 0)
Expand Down Expand Up @@ -480,7 +480,7 @@ SAMFieldList *sam3ParseReply(const char *rep) {
if ((e1 = xstrtokend(e)) == NULL)
return NULL;
//
if ((first = last = c = malloc(sizeof(SAMFieldList))) == NULL)
if ((first = last = c = (SAMFieldList*)malloc(sizeof(SAMFieldList))) == NULL)
return NULL;
c->next = NULL;
c->name = c->value = NULL;
Expand All @@ -501,14 +501,14 @@ SAMFieldList *sam3ParseReply(const char *rep) {
if (libsam3_debug)
fprintf(stderr, "<%s>\n", p);
//
if ((c = malloc(sizeof(SAMFieldList))) == NULL)
if ((c = (SAMFieldList*)malloc(sizeof(SAMFieldList))) == NULL)
return NULL;
c->next = NULL;
c->name = c->value = NULL;
last->next = c;
last = c;
//
if ((e1 = memchr(p, '=', e - p)) != NULL) {
if ((e1 = (char*)memchr(p, '=', e - p)) != NULL) {
// key=value
if ((c->name = xstrdup(p, e1 - p)) == NULL)
goto error;
Expand Down Expand Up @@ -964,7 +964,7 @@ Sam3Connection *sam3StreamConnect(Sam3Session *ses, const char *destkey) {
strcpyerr(ses, "INVALID_KEY");
return NULL;
}
if ((conn = calloc(1, sizeof(Sam3Connection))) == NULL) {
if ((conn = (Sam3Connection*)calloc(1, sizeof(Sam3Connection))) == NULL) {
strcpyerr(ses, "NO_MEMORY");
return NULL;
}
Expand Down Expand Up @@ -1025,7 +1025,7 @@ Sam3Connection *sam3StreamAccept(Sam3Session *ses) {
strcpyerr(ses, "INVALID_SESSION");
return NULL;
}
if ((conn = calloc(1, sizeof(Sam3Connection))) == NULL) {
if ((conn = (Sam3Connection*)calloc(1, sizeof(Sam3Connection))) == NULL) {
strcpyerr(ses, "NO_MEMORY");
return NULL;
}
Expand Down Expand Up @@ -1159,7 +1159,7 @@ int sam3DatagramSend(Sam3Session *ses, const char *destkey, const void *buf,
return -1;
}
dbufsz = bufsize + 4 + strlen(destkey) + 1 + strlen(ses->channel) + 1;
if ((dbuf = malloc(dbufsz)) == NULL) {
if ((dbuf = (char*)malloc(dbufsz)) == NULL) {
strcpyerr(ses, "OUT_OF_MEMORY");
return -1;
}
Expand Down