From: Art Cancro Date: Wed, 24 Mar 2004 03:25:20 +0000 (+0000) Subject: * Removed the built-in memory leak checker. It wasn't threadsafe and X-Git-Tag: v7.86~5507 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=f154d097d062caf389d9fd5c096cf048d9f5724e * Removed the built-in memory leak checker. It wasn't threadsafe and there now exist third-party utilities that do this job better. --- diff --git a/citadel/ChangeLog b/citadel/ChangeLog index 612706149..abaaf88b3 100644 --- a/citadel/ChangeLog +++ b/citadel/ChangeLog @@ -1,4 +1,8 @@ $Log$ + Revision 614.96 2004/03/24 03:25:19 ajc + * Removed the built-in memory leak checker. It wasn't threadsafe and + there now exist third-party utilities that do this job better. + Revision 614.95 2004/03/24 02:59:19 ajc * After initializing the database, chown and chmod all files in the data/ directory correctly to avoid EPERM errors later on when we drop root privs @@ -5590,3 +5594,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant Fri Jul 10 1998 Art Cancro * Initial CVS import + diff --git a/citadel/citserver.c b/citadel/citserver.c index ae36d036b..440137631 100644 --- a/citadel/citserver.c +++ b/citadel/citserver.c @@ -161,9 +161,9 @@ void deallocate_user_data(struct CitContext *con) lprintf(CTDL_DEBUG, "Deallocating user data symbol %ld\n", con->FirstSessData->sym_id); if (con->FirstSessData->sym_data != NULL) - phree(con->FirstSessData->sym_data); + free(con->FirstSessData->sym_data); ptr = con->FirstSessData->next; - phree(con->FirstSessData); + free(con->FirstSessData); con->FirstSessData = ptr; } end_critical_section(S_SESSION_TABLE); @@ -240,7 +240,7 @@ void RemoveContext (struct CitContext *con) /* This is where we used to check for scheduled shutdowns. */ /* Free up the memory used by this context */ - phree(con); + free(con); lprintf(CTDL_DEBUG, "Done with RemoveContext()\n"); } @@ -287,9 +287,9 @@ void CtdlAllocUserData(unsigned long requested_sym, size_t num_bytes) } /* Grab us some memory! Dem's good eatin' !! */ - ptr = mallok(sizeof(struct CtdlSessData)); + ptr = malloc(sizeof(struct CtdlSessData)); ptr->sym_id = requested_sym; - ptr->sym_data = mallok(num_bytes); + ptr->sym_data = malloc(num_bytes); memset(ptr->sym_data, 0, num_bytes); begin_critical_section(S_SESSION_TABLE); @@ -310,7 +310,7 @@ void CtdlReallocUserData(unsigned long requested_sym, size_t num_bytes) for (ptr = CC->FirstSessData; ptr != NULL; ptr = ptr->next) { if (ptr->sym_id == requested_sym) { - ptr->sym_data = reallok(ptr->sym_data, num_bytes); + ptr->sym_data = realloc(ptr->sym_data, num_bytes); return; } } @@ -534,8 +534,8 @@ void cmd_mesg(char *mname) extract(buf,mname,0); - dirs[0]=mallok(64); - dirs[1]=mallok(64); + dirs[0]=malloc(64); + dirs[1]=malloc(64); strcpy(dirs[0],"messages"); strcpy(dirs[1],"help"); snprintf(buf2, sizeof buf2, "%s.%d.%d", buf, CC->cs_clientdev, CC->cs_clienttyp); @@ -547,8 +547,8 @@ void cmd_mesg(char *mname) mesg_locate(targ,sizeof targ,buf,2,(const char **)dirs); } } - phree(dirs[0]); - phree(dirs[1]); + free(dirs[0]); + free(dirs[1]); if (strlen(targ)==0) { cprintf("%d '%s' not found.\n",ERROR + FILE_NOT_FOUND, mname); @@ -592,13 +592,13 @@ void cmd_emsg(char *mname) if (buf[a] == '/') buf[a] = '.'; } - dirs[0]=mallok(64); - dirs[1]=mallok(64); + dirs[0]=malloc(64); + dirs[1]=malloc(64); strcpy(dirs[0],"messages"); strcpy(dirs[1],"help"); mesg_locate(targ,sizeof targ,buf,2,(const char**)dirs); - phree(dirs[0]); - phree(dirs[1]); + free(dirs[0]); + free(dirs[1]); if (strlen(targ)==0) { snprintf(targ, sizeof targ, "./help/%s", buf); @@ -1303,12 +1303,6 @@ void do_command_loop(void) { cmd_isme(&cmdbuf[5]); } -#ifdef DEBUG_MEMORY_LEAKS - else if (!strncasecmp(cmdbuf, "LEAK", 4)) { - dump_tracked(); - } -#endif - else if (!DLoader_Exec_Cmd(cmdbuf)) { cprintf("%d Unrecognized or unsupported command.\n", ERROR + CMD_NOT_SUPPORTED); } diff --git a/citadel/control.c b/citadel/control.c index 973c10fd4..e47838d45 100644 --- a/citadel/control.c +++ b/citadel/control.c @@ -391,7 +391,7 @@ void cmd_conf(char *argbuf) if (confptr[strlen(confptr) - 1] != 10) client_write("\n", 1); cprintf("000\n"); - phree(confptr); + free(confptr); } else { cprintf("%d No such configuration.\n", ERROR + ILLEGAL_VALUE); @@ -404,7 +404,7 @@ void cmd_conf(char *argbuf) confptr = CtdlReadMessageBody("000", config.c_maxmsglen, NULL, 0); CtdlPutSysConfig(confname, confptr); - phree(confptr); + free(confptr); } else { diff --git a/citadel/database_sleepycat.c b/citadel/database_sleepycat.c index 5e3fb37a7..5117bb590 100644 --- a/citadel/database_sleepycat.c +++ b/citadel/database_sleepycat.c @@ -152,7 +152,7 @@ static void check_handles(void *arg) { static void dest_tsd(void *arg) { if (arg != NULL) { check_handles(arg); - phree(arg); + free(arg); } } @@ -170,7 +170,7 @@ void cdb_allocate_tsd(void) { if (pthread_getspecific(tsdkey) != NULL) return; - tsd = mallok(sizeof(struct cdbtsd)); + tsd = malloc(sizeof(struct cdbtsd)); tsd->tid = NULL; @@ -463,7 +463,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) { sourceLen = (uLongf) zheader.compressed_len; destLen = (uLongf) zheader.uncompressed_len; - uncompressed_data = mallok(zheader.uncompressed_len); + uncompressed_data = malloc(zheader.uncompressed_len); if (uncompress( (Bytef *) uncompressed_data, &destLen, @@ -474,7 +474,7 @@ void cdb_decompress_if_necessary(struct cdbdata *cdb) { abort(); } - phree(cdb->ptr); + free(cdb->ptr); cdb->len = (size_t) destLen; cdb->ptr = uncompressed_data; } @@ -519,7 +519,7 @@ int cdb_store(int cdb, buffer_len = ( (cdatalen * 101) / 100 ) + 100 + sizeof(struct CtdlCompressHeader) ; destLen = (uLongf) buffer_len; - compressed_data = mallok(buffer_len); + compressed_data = malloc(buffer_len); if (compress2( (Bytef *) (compressed_data + sizeof(struct CtdlCompressHeader)), @@ -553,7 +553,7 @@ int cdb_store(int cdb, abort(); } #ifdef HAVE_ZLIB - if (compressing) phree(compressed_data); + if (compressing) free(compressed_data); #endif return ret; @@ -586,7 +586,7 @@ int cdb_store(int cdb, { txcommit(tid); #ifdef HAVE_ZLIB - if (compressing) phree(compressed_data); + if (compressing) free(compressed_data); #endif return ret; } @@ -714,7 +714,7 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) } if (ret != 0) return NULL; - tempcdb = (struct cdbdata *) mallok(sizeof(struct cdbdata)); + tempcdb = (struct cdbdata *) malloc(sizeof(struct cdbdata)); if (tempcdb == NULL) { @@ -737,8 +737,8 @@ struct cdbdata *cdb_fetch(int cdb, void *key, int keylen) */ void cdb_free(struct cdbdata *cdb) { - phree(cdb->ptr); - phree(cdb); + free(cdb->ptr); + free(cdb); } void cdb_close_cursor(int cdb) @@ -801,7 +801,7 @@ struct cdbdata *cdb_next_item(int cdb) return NULL; /* presumably, end of file */ } - cdbret = (struct cdbdata *) mallok(sizeof(struct cdbdata)); + cdbret = (struct cdbdata *) malloc(sizeof(struct cdbdata)); cdbret->len = data.size; cdbret->ptr = data.data; #ifdef HAVE_ZLIB diff --git a/citadel/domain.c b/citadel/domain.c index 8af3bc37b..9a825928d 100644 --- a/citadel/domain.c +++ b/citadel/domain.c @@ -151,7 +151,7 @@ int getmx(char *mxbuf, char *dest) { C_IN, T_MX, (unsigned char *)answer.bytes, sizeof(answer) ); if (ret < 0) { - mxrecs = mallok(sizeof(struct mx)); + mxrecs = malloc(sizeof(struct mx)); mxrecs[0].pref = 0; strcpy(mxrecs[0].host, dest); num_mxrecs = 1; @@ -204,10 +204,10 @@ int getmx(char *mxbuf, char *dest) { ++num_mxrecs; if (mxrecs == NULL) { - mxrecs = mallok(sizeof(struct mx)); + mxrecs = malloc(sizeof(struct mx)); } else { - mxrecs = reallok(mxrecs, + mxrecs = realloc(mxrecs, (sizeof(struct mx) * num_mxrecs) ); } @@ -229,6 +229,6 @@ int getmx(char *mxbuf, char *dest) { strcat(mxbuf, mxrecs[n].host); strcat(mxbuf, "|"); } - phree(mxrecs); + free(mxrecs); return(num_mxrecs); } diff --git a/citadel/file_ops.c b/citadel/file_ops.c index 3a4478749..cc0fd8ee2 100644 --- a/citadel/file_ops.c +++ b/citadel/file_ops.c @@ -65,9 +65,9 @@ int network_talking_to(char *nodename, int operation) { switch(operation) { case NTT_ADD: - if (nttlist == NULL) nttlist = strdoop(""); + if (nttlist == NULL) nttlist = strdup(""); if (nttlist == NULL) break; - nttlist = (char *)reallok(nttlist, + nttlist = (char *)realloc(nttlist, (strlen(nttlist) + strlen(nodename) + 3) ); strcat(nttlist, "|"); strcat(nttlist, nodename); @@ -76,7 +76,7 @@ int network_talking_to(char *nodename, int operation) { case NTT_REMOVE: if (nttlist == NULL) break; if (strlen(nttlist) == 0) break; - ptr = mallok(strlen(nttlist)); + ptr = malloc(strlen(nttlist)); if (ptr == NULL) break; strcpy(ptr, ""); for (i = 0; i < num_tokens(nttlist, '|'); ++i) { @@ -87,7 +87,7 @@ int network_talking_to(char *nodename, int operation) { strcat(ptr, "|"); } } - phree(nttlist); + free(nttlist); nttlist = ptr; break; diff --git a/citadel/html.c b/citadel/html.c index 697547a14..4b9102528 100644 --- a/citadel/html.c +++ b/citadel/html.c @@ -69,7 +69,7 @@ char *html_to_ascii(char *inputmsg, int screenwidth, int do_citaformat) { strcpy(outbuf, ""); outptr_buffer_size = strlen(inptr) + SIZ; - outptr = mallok(outptr_buffer_size); + outptr = malloc(outptr_buffer_size); if (outptr == NULL) return NULL; strcpy(outptr, ""); output_len = 0; diff --git a/citadel/imap_fetch.c b/citadel/imap_fetch.c index cbc3298cf..88542173a 100644 --- a/citadel/imap_fetch.c +++ b/citadel/imap_fetch.c @@ -398,7 +398,7 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) { fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Sender"); if (fieldptr != NULL) { imap_output_envelope_addr(fieldptr); - phree(fieldptr); + free(fieldptr); } else { imap_output_envelope_from(msg); @@ -408,7 +408,7 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) { fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Reply-to"); if (fieldptr != NULL) { imap_output_envelope_addr(fieldptr); - phree(fieldptr); + free(fieldptr); } else { imap_output_envelope_from(msg); @@ -420,18 +420,18 @@ void imap_fetch_envelope(long msgnum, struct CtdlMessage *msg) { /* Cc */ fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Cc"); imap_output_envelope_addr(fieldptr); - if (fieldptr != NULL) phree(fieldptr); + if (fieldptr != NULL) free(fieldptr); /* Bcc */ fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "Bcc"); imap_output_envelope_addr(fieldptr); - if (fieldptr != NULL) phree(fieldptr); + if (fieldptr != NULL) free(fieldptr); /* In-reply-to */ fieldptr = rfc822_fetch_field(msg->cm_fields['M'], "In-reply-to"); imap_strout(fieldptr); cprintf(" "); - if (fieldptr != NULL) phree(fieldptr); + if (fieldptr != NULL) free(fieldptr); /* message ID */ imap_strout(msg->cm_fields['I']); @@ -456,7 +456,7 @@ void imap_strip_headers(FILE *fp, char *section) { int ok = 0; int done_headers = 0; - which_fields = strdoop(section); + which_fields = strdup(section); if (!strncasecmp(which_fields, "HEADER.FIELDS", 13)) doing_headers = 1; @@ -474,7 +474,7 @@ void imap_strip_headers(FILE *fp, char *section) { num_parms = imap_parameterize(parms, which_fields); fseek(fp, 0L, SEEK_END); - boiled_headers = mallok((size_t)(ftell(fp) + 256L)); + boiled_headers = malloc((size_t)(ftell(fp) + 256L)); strcpy(boiled_headers, ""); rewind(fp); @@ -515,8 +515,8 @@ void imap_strip_headers(FILE *fp, char *section) { ftruncate(fileno(fp), ftell(fp)); fflush(fp); rewind(fp); - phree(which_fields); - phree(boiled_headers); + free(which_fields); + free(boiled_headers); } diff --git a/citadel/imap_misc.c b/citadel/imap_misc.c index e9d33ad95..8b56dfae2 100644 --- a/citadel/imap_misc.c +++ b/citadel/imap_misc.c @@ -156,7 +156,7 @@ void imap_print_express_messages(void) { while (ptr != NULL) { stamp = localtime(&(ptr->timestamp)); size = strlen(ptr->text) + SIZ; - dumpomatic = mallok(size); + dumpomatic = malloc(size); strcpy(dumpomatic, ""); if (ptr->flags && EM_BROADCAST) strcat(dumpomatic, "Broadcast message "); @@ -188,8 +188,8 @@ void imap_print_express_messages(void) { strcat(dumpomatic, ptr->text); holdptr = ptr->next; - if (ptr->text != NULL) phree(ptr->text); - phree(ptr); + if (ptr->text != NULL) free(ptr->text); + free(ptr); ptr = holdptr; for (i=0; itransmitted_message = mallok(literal_length + 1); + IMAP->transmitted_message = malloc(literal_length + 1); if (IMAP->transmitted_message == NULL) { cprintf("%s NO Cannot allocate memory.\r\n", parms[0]); return; @@ -327,12 +327,12 @@ void imap_append(int num_parms, char *parms[]) { */ if (CC->logged_in) { if ( (CC->room.QRflags & QR_MAILBOX) == 0) { - if (msg->cm_fields['A'] != NULL) phree(msg->cm_fields['A']); - if (msg->cm_fields['N'] != NULL) phree(msg->cm_fields['N']); - if (msg->cm_fields['H'] != NULL) phree(msg->cm_fields['H']); - msg->cm_fields['A'] = strdoop(CC->user.fullname); - msg->cm_fields['N'] = strdoop(config.c_nodename); - msg->cm_fields['H'] = strdoop(config.c_humannode); + if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']); + if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']); + if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']); + msg->cm_fields['A'] = strdup(CC->user.fullname); + msg->cm_fields['N'] = strdup(config.c_nodename); + msg->cm_fields['H'] = strdup(config.c_humannode); } } diff --git a/citadel/imap_search.c b/citadel/imap_search.c index 894a96e95..dce7e605d 100644 --- a/citadel/imap_search.c +++ b/citadel/imap_search.c @@ -107,7 +107,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *msg, if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) { match = 1; } - phree(fieldptr); + free(fieldptr); } pos += 2; } @@ -135,7 +135,7 @@ int imap_do_search_msg(int seq, struct CtdlMessage *msg, if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) { match = 1; } - phree(fieldptr); + free(fieldptr); } pos += 2; } diff --git a/citadel/internet_addressing.c b/citadel/internet_addressing.c index e2940f9d9..3e6d7bb55 100644 --- a/citadel/internet_addressing.c +++ b/citadel/internet_addressing.c @@ -309,7 +309,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { if (colonpos < 0) return(0); /* no colon? not a valid header line */ - key = mallok((end - beg) + 2); + key = malloc((end - beg) + 2); safestrncpy(key, &rfc822[beg], (end-beg)+1); key[colonpos - beg] = 0; value = &key[(colonpos - beg) + 1]; @@ -327,7 +327,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { if (parsed_date < 0L) parsed_date = time(NULL); snprintf(buf, sizeof buf, "%ld", (long)parsed_date ); if (msg->cm_fields['T'] == NULL) - msg->cm_fields['T'] = strdoop(buf); + msg->cm_fields['T'] = strdup(buf); processed = 1; } @@ -336,22 +336,22 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { lprintf(CTDL_DEBUG, "Converted to <%s@%s> (%s)\n", user, node, name); snprintf(addr, sizeof addr, "%s@%s", user, node); if (msg->cm_fields['A'] == NULL) - msg->cm_fields['A'] = strdoop(name); + msg->cm_fields['A'] = strdup(name); processed = 1; if (msg->cm_fields['F'] == NULL) - msg->cm_fields['F'] = strdoop(addr); + msg->cm_fields['F'] = strdup(addr); processed = 1; } else if (!strcasecmp(key, "Subject")) { if (msg->cm_fields['U'] == NULL) - msg->cm_fields['U'] = strdoop(value); + msg->cm_fields['U'] = strdup(value); processed = 1; } else if (!strcasecmp(key, "To")) { if (msg->cm_fields['R'] == NULL) - msg->cm_fields['R'] = strdoop(value); + msg->cm_fields['R'] = strdup(value); processed = 1; } @@ -361,7 +361,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { } if (msg->cm_fields['I'] == NULL) { - msg->cm_fields['I'] = strdoop(value); + msg->cm_fields['I'] = strdup(value); /* Strip angle brackets */ while (haschar(msg->cm_fields['I'], '<') > 0) { @@ -377,7 +377,7 @@ int convert_field(struct CtdlMessage *msg, int beg, int end) { } /* Clean up and move on. */ - phree(key); /* Don't free 'value', it's actually the same buffer */ + free(key); /* Don't free 'value', it's actually the same buffer */ return(processed); } @@ -397,7 +397,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { char buf[SIZ]; int converted; - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); if (msg == NULL) return msg; memset(msg, 0, sizeof(struct CtdlMessage)); @@ -471,7 +471,7 @@ struct CtdlMessage *convert_internet_message(char *rfc822) { /* If there's no timestamp on this message, set it to now. */ if (msg->cm_fields['T'] == NULL) { snprintf(buf, sizeof buf, "%ld", (long)time(NULL)); - msg->cm_fields['T'] = strdoop(buf); + msg->cm_fields['T'] = strdup(buf); } lprintf(CTDL_DEBUG, "RFC822 length remaining after conversion = %ld\n", @@ -513,7 +513,7 @@ char *rfc822_fetch_field(char *rfc822, char *fieldname) { if (field_start == NULL) return(NULL); if (field_start > end_of_headers) return(NULL); - fieldbuf = mallok(SIZ); + fieldbuf = malloc(SIZ); strcpy(fieldbuf, ""); ptr = field_start; diff --git a/citadel/locate_host.c b/citadel/locate_host.c index 09aef6545..3bcecf5a5 100644 --- a/citadel/locate_host.c +++ b/citadel/locate_host.c @@ -60,9 +60,9 @@ bad_dns: section */ } /* check if the forward DNS agrees; if not, they're spoofing */ - j = strdoop(ch->h_name); + j = strdup(ch->h_name); ch = gethostbyname(j); - phree(j); + free(j); if (ch == NULL) goto bad_dns; diff --git a/citadel/mime_parser.c b/citadel/mime_parser.c index c77e1cd61..321a2df32 100644 --- a/citadel/mime_parser.c +++ b/citadel/mime_parser.c @@ -203,7 +203,7 @@ void mime_decode(char *partnum, * will never be larger than the encoded data. This is a safe * assumption with base64, uuencode, and quoted-printable. */ - decoded = mallok(length+2048); + decoded = malloc(length+2048); if (decoded == NULL) { return; } @@ -222,7 +222,7 @@ void mime_decode(char *partnum, content_type, bytes_decoded, "binary", userdata); } - phree(decoded); + free(decoded); } /* @@ -293,34 +293,34 @@ void the_mime_parser(char *partnum, ptr = content_start; content_length = 0; - boundary = mallok(SIZ); + boundary = malloc(SIZ); memset(boundary, 0, SIZ); - startary = mallok(SIZ); + startary = malloc(SIZ); memset(startary, 0, SIZ); - endary = mallok(SIZ); + endary = malloc(SIZ); memset(endary, 0, SIZ); - header = mallok(SIZ); + header = malloc(SIZ); memset(header, 0, SIZ); - content_type = mallok(SIZ); + content_type = malloc(SIZ); memset(content_type, 0, SIZ); - encoding = mallok(SIZ); + encoding = malloc(SIZ); memset(encoding, 0, SIZ); - content_type_name = mallok(SIZ); + content_type_name = malloc(SIZ); memset(content_type_name, 0, SIZ); - content_disposition_name = mallok(SIZ); + content_disposition_name = malloc(SIZ); memset(content_disposition_name, 0, SIZ); - filename = mallok(SIZ); + filename = malloc(SIZ); memset(filename, 0, SIZ); - disposition = mallok(SIZ); + disposition = malloc(SIZ); memset(disposition, 0, SIZ); /* If the caller didn't supply an endpointer, generate one by measure */ @@ -487,16 +487,16 @@ void the_mime_parser(char *partnum, } end_parser: /* free the buffers! end the oppression!! */ - phree(boundary); - phree(startary); - phree(endary); - phree(header); - phree(content_type); - phree(encoding); - phree(content_type_name); - phree(content_disposition_name); - phree(filename); - phree(disposition); + free(boundary); + free(startary); + free(endary); + free(header); + free(content_type); + free(encoding); + free(content_type_name); + free(content_disposition_name); + free(filename); + free(disposition); } diff --git a/citadel/mime_parser.h b/citadel/mime_parser.h index 9464f01fa..523eb32a9 100644 --- a/citadel/mime_parser.h +++ b/citadel/mime_parser.h @@ -11,21 +11,6 @@ #define SIZ 4096 #endif -#ifndef mallok -#define mallok(x) malloc(x) -#endif - -#ifndef phree -#define phree(x) free(x) -#endif - -#ifndef reallok -#define reallok(x,y) realloc(x,y) -#endif - -#ifndef strdoop -#define strdoop(x) strdup(x) -#endif /* * Declarations for functions in the parser diff --git a/citadel/msgbase.c b/citadel/msgbase.c index 55c30c319..d1e0a2dc8 100644 --- a/citadel/msgbase.c +++ b/citadel/msgbase.c @@ -211,11 +211,11 @@ int alias(char *name) extract_token(buf, ignetcfg, i, '\n'); extract_token(testnode, buf, 0, '|'); if (!strcasecmp(node, testnode)) { - phree(ignetcfg); + free(ignetcfg); return(MES_IGNET); } } - phree(ignetcfg); + free(ignetcfg); /* * Then try nodes that are two or more hops away. @@ -225,11 +225,11 @@ int alias(char *name) extract_token(buf, ignetmap, i, '\n'); extract_token(testnode, buf, 0, '|'); if (!strcasecmp(node, testnode)) { - phree(ignetmap); + free(ignetmap); return(MES_IGNET); } } - phree(ignetmap); + free(ignetmap); /* If we get to this point it's an invalid node name */ return (MES_ERROR); @@ -328,7 +328,7 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) { /* Load the message list */ cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -391,7 +391,7 @@ void CtdlSetSeen(long target_msgnum, int target_setting, int which_set) { if (which_set == ctdlsetseen_answered) strcpy(vbuf.v_answered, newseen); lprintf(CTDL_DEBUG, " after optimize: %s\n", newseen); - phree(msglist); + free(msglist); CtdlSetRelationship(&vbuf, &CC->user, &CC->room); } @@ -428,7 +428,7 @@ int CtdlForEachMessage(int mode, long ref, /* Load the message list */ cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -515,7 +515,7 @@ int CtdlForEachMessage(int mode, long ref, ++num_processed; } } - phree(msglist); /* Clean up */ + free(msglist); /* Clean up */ return num_processed; } @@ -563,7 +563,7 @@ void cmd_msgs(char *cmdbuf) cprintf("%d Send template then receive message list\n", START_CHAT_MODE); template = (struct CtdlMessage *) - mallok(sizeof(struct CtdlMessage)); + malloc(sizeof(struct CtdlMessage)); memset(template, 0, sizeof(struct CtdlMessage)); while(client_gets(buf), strcmp(buf,"000")) { extract(tfield, buf, 0); @@ -571,7 +571,7 @@ void cmd_msgs(char *cmdbuf) for (i='A'; i<='Z'; ++i) if (msgkeys[i]!=NULL) { if (!strcasecmp(tfield, msgkeys[i])) { template->cm_fields[i] = - strdoop(tvalue); + strdup(tvalue); } } } @@ -807,7 +807,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum) cdb_free(dmsgtext); return NULL; } - ret = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage)); + ret = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); memset(ret, 0, sizeof(struct CtdlMessage)); ret->cm_magic = CTDLMESSAGE_MAGIC; @@ -824,7 +824,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum) if (field_length == 0) break; field_header = *mptr++; - ret->cm_fields[field_header] = mallok(field_length); + ret->cm_fields[field_header] = malloc(field_length); strcpy(ret->cm_fields[field_header], mptr); while (*mptr++ != 0); /* advance to next field */ @@ -835,7 +835,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum) /* Always make sure there's something in the msg text field */ if (ret->cm_fields['M'] == NULL) - ret->cm_fields['M'] = strdoop("\n"); + ret->cm_fields['M'] = strdup("\n"); /* Perform "before read" hooks (aborting if any return nonzero) */ if (PerformMessageHooks(ret, EVT_BEFOREREAD) > 0) { @@ -873,11 +873,11 @@ void CtdlFreeMessage(struct CtdlMessage *msg) for (i = 0; i < 256; ++i) if (msg->cm_fields[i] != NULL) { - phree(msg->cm_fields[i]); + free(msg->cm_fields[i]); } msg->cm_magic = 0; /* just in case */ - phree(msg); + free(msg); } @@ -958,7 +958,7 @@ void fixed_output(char *name, char *filename, char *partnum, char *disp, if (ptr[wlen-1] != '\n') { cprintf("\n"); } - phree(ptr); + free(ptr); } else if (strncasecmp(cbtype, "multipart/", 10)) { cprintf("Part %s: %s (%s) (%ld bytes)\r\n", @@ -1544,7 +1544,7 @@ void cmd_msg3(char *cmdbuf) cprintf("%d %ld\n", BINARY_FOLLOWS, (long)smr.len); client_write(smr.ser, smr.len); - phree(smr.ser); + free(smr.ser); } @@ -1649,7 +1649,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { msglist = NULL; num_msgs = 0; } else { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); if (msglist == NULL) lprintf(CTDL_ALERT, "ERROR malloc msglist!\n"); num_msgs = cdbfr->len / sizeof(long); @@ -1673,7 +1673,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { /* Now add the new message */ ++num_msgs; - msglist = reallok(msglist, + msglist = realloc(msglist, (num_msgs * sizeof(long))); if (msglist == NULL) { @@ -1692,7 +1692,7 @@ int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int flags) { msglist, num_msgs * sizeof(long)); /* Free up the memory we used. */ - phree(msglist); + free(msglist); /* Update the highest-message pointer and unlock the room. */ CC->room.QRhighest = highest_msg; @@ -1733,7 +1733,7 @@ long send_message(struct CtdlMessage *msg, /* pointer to buffer */ /* Generate an ID if we don't have one already */ if (msg->cm_fields['I']==NULL) { - msg->cm_fields['I'] = strdoop(msgidbuf); + msg->cm_fields['I'] = strdup(msgidbuf); } serialize_message(&smr, msg); @@ -1761,7 +1761,7 @@ long send_message(struct CtdlMessage *msg, /* pointer to buffer */ } /* Free the memory we used for the serialized message */ - phree(smr.ser); + free(smr.ser); /* Return the *local* message ID to the caller * (even if we're storing an incoming network message) @@ -1793,7 +1793,7 @@ void serialize_message(struct ser_ret *ret, /* return values */ strlen(msg->cm_fields[(int)forder[i]]) + 2; lprintf(CTDL_DEBUG, "serialize_message() calling malloc(%ld)\n", (long)ret->len); - ret->ser = mallok(ret->len); + ret->ser = malloc(ret->len); if (ret->ser == NULL) { ret->len = 0; return; @@ -1868,7 +1868,7 @@ int ReplicationChecks(struct CtdlMessage *msg) { template = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); memset(template, 0, sizeof(struct CtdlMessage)); - template->cm_fields['E'] = strdoop(msg->cm_fields['E']); + template->cm_fields['E'] = strdup(msg->cm_fields['E']); CtdlForEachMessage(MSGS_ALL, 0L, NULL, template, check_repl, NULL); @@ -1921,7 +1921,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (msg->cm_fields['T'] == NULL) { lprintf(CTDL_DEBUG, "Generating timestamp\n"); snprintf(aaa, sizeof aaa, "%ld", (long)time(NULL)); - msg->cm_fields['T'] = strdoop(aaa); + msg->cm_fields['T'] = strdup(aaa); } /* If this message has no path, we generate one. @@ -1929,7 +1929,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (msg->cm_fields['P'] == NULL) { lprintf(CTDL_DEBUG, "Generating path\n"); if (msg->cm_fields['A'] != NULL) { - msg->cm_fields['P'] = strdoop(msg->cm_fields['A']); + msg->cm_fields['P'] = strdup(msg->cm_fields['A']); for (a=0; acm_fields['P']); ++a) { if (isspace(msg->cm_fields['P'][a])) { msg->cm_fields['P'][a] = ' '; @@ -1937,7 +1937,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ } } else { - msg->cm_fields['P'] = strdoop("unknown"); + msg->cm_fields['P'] = strdup("unknown"); } } @@ -2016,7 +2016,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ * If this message has no O (room) field, generate one. */ if (msg->cm_fields['O'] == NULL) { - msg->cm_fields['O'] = strdoop(CC->room.QRname); + msg->cm_fields['O'] = strdup(CC->room.QRname); } /* Perform "before save" hooks (aborting if any return nonzero) */ @@ -2117,8 +2117,8 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ hold_R = msg->cm_fields['R']; hold_D = msg->cm_fields['D']; - msg->cm_fields['R'] = mallok(SIZ); - msg->cm_fields['D'] = mallok(SIZ); + msg->cm_fields['R'] = malloc(SIZ); + msg->cm_fields['D'] = malloc(SIZ); extract_token(msg->cm_fields['R'], recipient, 0, '@'); extract_token(msg->cm_fields['D'], recipient, 1, '@'); @@ -2132,11 +2132,11 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ fwrite(smr.ser, smr.len, 1, network_fp); fclose(network_fp); } - phree(smr.ser); + free(smr.ser); } - phree(msg->cm_fields['R']); - phree(msg->cm_fields['D']); + free(msg->cm_fields['R']); + free(msg->cm_fields['D']); msg->cm_fields['R'] = hold_R; msg->cm_fields['D'] = hold_D; } @@ -2154,7 +2154,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ if (recps != NULL) if (recps->num_internet > 0) { lprintf(CTDL_DEBUG, "Generating delivery instructions\n"); - instr = mallok(SIZ * 2); + instr = malloc(SIZ * 2); snprintf(instr, SIZ * 2, "Content-type: %s\n\nmsgid|%ld\nsubmitted|%ld\n" "bounceto|%s@%s\n", @@ -2169,12 +2169,12 @@ long CtdlSubmitMsg(struct CtdlMessage *msg, /* message to save */ "remote|%s|0||\n", recipient); } - imsg = mallok(sizeof(struct CtdlMessage)); + imsg = malloc(sizeof(struct CtdlMessage)); memset(imsg, 0, sizeof(struct CtdlMessage)); imsg->cm_magic = CTDLMESSAGE_MAGIC; imsg->cm_anon_type = MES_NORMAL; imsg->cm_format_type = FMT_RFC822; - imsg->cm_fields['A'] = strdoop("Citadel"); + imsg->cm_fields['A'] = strdup("Citadel"); imsg->cm_fields['M'] = instr; CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM); CtdlFreeMessage(imsg); @@ -2194,26 +2194,26 @@ void quickie_message(char *from, char *to, char *room, char *text, struct CtdlMessage *msg; struct recptypes *recp = NULL; - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; msg->cm_format_type = format_type; - msg->cm_fields['A'] = strdoop(from); - if (room != NULL) msg->cm_fields['O'] = strdoop(room); - msg->cm_fields['N'] = strdoop(NODENAME); + msg->cm_fields['A'] = strdup(from); + if (room != NULL) msg->cm_fields['O'] = strdup(room); + msg->cm_fields['N'] = strdup(NODENAME); if (to != NULL) { - msg->cm_fields['R'] = strdoop(to); + msg->cm_fields['R'] = strdup(to); recp = validate_recipients(to); } if (subject != NULL) { - msg->cm_fields['U'] = strdoop(subject); + msg->cm_fields['U'] = strdup(subject); } - msg->cm_fields['M'] = strdoop(text); + msg->cm_fields['M'] = strdup(text); CtdlSubmitMsg(msg, recp, room); CtdlFreeMessage(msg); - if (recp != NULL) phree(recp); + if (recp != NULL) free(recp); } @@ -2237,7 +2237,7 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ int finished = 0; if (exist == NULL) { - m = mallok(4096); + m = malloc(4096); m[0] = 0; buffer_len = 4096; message_len = 0; @@ -2245,9 +2245,9 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ else { message_len = strlen(exist); buffer_len = message_len + 4096; - m = reallok(exist, buffer_len); + m = realloc(exist, buffer_len); if (m == NULL) { - phree(exist); + free(exist); return m; } } @@ -2274,7 +2274,7 @@ char *CtdlReadMessageBody(char *terminator, /* token signalling EOT */ /* augment the buffer if we have to */ if ((message_len + linelen) >= buffer_len) { - ptr = reallok(m, (buffer_len * 2) ); + ptr = realloc(m, (buffer_len * 2) ); if (ptr == NULL) { /* flush if can't allocate */ flushing = 1; } else { @@ -2325,7 +2325,7 @@ struct CtdlMessage *CtdlMakeMessage( char buf[SIZ]; struct CtdlMessage *msg; - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = type; @@ -2337,41 +2337,41 @@ struct CtdlMessage *CtdlMakeMessage( striplt(recipient); snprintf(buf, sizeof buf, "cit%ld", author->usernum); /* Path */ - msg->cm_fields['P'] = strdoop(buf); + msg->cm_fields['P'] = strdup(buf); snprintf(buf, sizeof buf, "%ld", (long)time(NULL)); /* timestamp */ - msg->cm_fields['T'] = strdoop(buf); + msg->cm_fields['T'] = strdup(buf); if (fake_name[0]) /* author */ - msg->cm_fields['A'] = strdoop(fake_name); + msg->cm_fields['A'] = strdup(fake_name); else - msg->cm_fields['A'] = strdoop(author->fullname); + msg->cm_fields['A'] = strdup(author->fullname); if (CC->room.QRflags & QR_MAILBOX) { /* room */ - msg->cm_fields['O'] = strdoop(&CC->room.QRname[11]); + msg->cm_fields['O'] = strdup(&CC->room.QRname[11]); } else { - msg->cm_fields['O'] = strdoop(CC->room.QRname); + msg->cm_fields['O'] = strdup(CC->room.QRname); } - msg->cm_fields['N'] = strdoop(NODENAME); /* nodename */ - msg->cm_fields['H'] = strdoop(HUMANNODE); /* hnodename */ + msg->cm_fields['N'] = strdup(NODENAME); /* nodename */ + msg->cm_fields['H'] = strdup(HUMANNODE); /* hnodename */ if (recipient[0] != 0) { - msg->cm_fields['R'] = strdoop(recipient); + msg->cm_fields['R'] = strdup(recipient); } if (dest_node[0] != 0) { - msg->cm_fields['D'] = strdoop(dest_node); + msg->cm_fields['D'] = strdup(dest_node); } if ( (author == &CC->user) && (strlen(CC->cs_inet_email) > 0) ) { - msg->cm_fields['F'] = strdoop(CC->cs_inet_email); + msg->cm_fields['F'] = strdup(CC->cs_inet_email); } if (subject != NULL) { striplt(subject); if (strlen(subject) > 0) { - msg->cm_fields['U'] = strdoop(subject); + msg->cm_fields['U'] = strdup(subject); } } @@ -2685,7 +2685,7 @@ void cmd_ent0(char *entargs) if (valid->num_error > 0) { cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid->errormsg); - phree(valid); + free(valid); return; } if (valid->num_internet > 0) { @@ -2693,7 +2693,7 @@ void cmd_ent0(char *entargs) cprintf("%d You do not have permission " "to send Internet mail.\n", ERROR + HIGHER_ACCESS_REQUIRED); - phree(valid); + free(valid); return; } } @@ -2702,7 +2702,7 @@ void cmd_ent0(char *entargs) && (CC->user.axlevel < 4) ) { cprintf("%d Higher access required for network mail.\n", ERROR + HIGHER_ACCESS_REQUIRED); - phree(valid); + free(valid); return; } @@ -2711,7 +2711,7 @@ void cmd_ent0(char *entargs) && (!CC->internal_pgm)) { cprintf("%d You don't have access to Internet mail.\n", ERROR + HIGHER_ACCESS_REQUIRED); - phree(valid); + free(valid); return; } @@ -2738,7 +2738,7 @@ void cmd_ent0(char *entargs) if (post == 0) { cprintf("%d %s\n", CIT_OK, ((valid != NULL) ? valid->display_recp : "") ); - phree(valid); + free(valid); return; } @@ -2764,7 +2764,7 @@ void cmd_ent0(char *entargs) CtdlFreeMessage(msg); } CC->fake_postname[0] = '\0'; - phree(valid); + free(valid); return; } @@ -2802,8 +2802,8 @@ int CtdlDeleteMessages(char *room_name, /* which room */ cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); - dellist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); + dellist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -2856,8 +2856,8 @@ int CtdlDeleteMessages(char *room_name, /* which room */ } /* Now free the memory we used, and go away. */ - if (msglist != NULL) phree(msglist); - if (dellist != NULL) phree(dellist); + if (msglist != NULL) free(msglist); + if (dellist != NULL) free(dellist); lprintf(CTDL_DEBUG, "%d message(s) deleted.\n", num_deleted); return (num_deleted); } @@ -3110,16 +3110,16 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ rewind(fp); lprintf(CTDL_DEBUG, "Raw length is %ld\n", (long)raw_length); - raw_message = mallok((size_t)raw_length + 2); + raw_message = malloc((size_t)raw_length + 2); fread(raw_message, (size_t)raw_length, 1, fp); fclose(fp); if (is_binary) { - encoded_message = mallok((size_t) + encoded_message = malloc((size_t) (((raw_length * 134) / 100) + 4096 ) ); } else { - encoded_message = mallok((size_t)(raw_length + 4096)); + encoded_message = malloc((size_t)(raw_length + 4096)); } sprintf(encoded_message, "Content-type: %s\n", content_type); @@ -3151,18 +3151,18 @@ void CtdlWriteObject(char *req_room, /* Room to stuff it in */ ); } - phree(raw_message); + free(raw_message); lprintf(CTDL_DEBUG, "Allocating\n"); - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; msg->cm_format_type = 4; - msg->cm_fields['A'] = strdoop(CC->user.fullname); - msg->cm_fields['O'] = strdoop(req_room); - msg->cm_fields['N'] = strdoop(config.c_nodename); - msg->cm_fields['H'] = strdoop(config.c_humannode); + msg->cm_fields['A'] = strdup(CC->user.fullname); + msg->cm_fields['O'] = strdup(req_room); + msg->cm_fields['N'] = strdup(config.c_nodename); + msg->cm_fields['H'] = strdup(config.c_humannode); msg->cm_flags = flags; msg->cm_fields['M'] = encoded_message; @@ -3223,7 +3223,7 @@ char *CtdlGetSysConfig(char *sysconfname) { else { msg = CtdlFetchMessage(msgnum); if (msg != NULL) { - conf = strdoop(msg->cm_fields['M']); + conf = strdup(msg->cm_fields['M']); CtdlFreeMessage(msg); } else { @@ -3269,19 +3269,19 @@ int CtdlIsMe(char *addr) { if (recp == NULL) return(0); if (recp->num_local == 0) { - phree(recp); + free(recp); return(0); } for (i=0; inum_local; ++i) { extract(addr, recp->recp_local, i); if (!strcasecmp(addr, CC->user.fullname)) { - phree(recp); + free(recp); return(1); } } - phree(recp); + free(recp); return(0); } diff --git a/citadel/room_ops.c b/citadel/room_ops.c index 2edaeb98f..9b5b27830 100644 --- a/citadel/room_ops.c +++ b/citadel/room_ops.c @@ -350,11 +350,11 @@ struct floor *cgetfloor(int floor_num) { if (fetch_new) { lprintf(CTDL_DEBUG, "fetch_new is active ... going to disk\n"); - fl = mallok(sizeof(struct floor)); + fl = malloc(sizeof(struct floor)); getfloor(fl, floor_num); begin_critical_section(S_FLOORCACHE); if (floorcache[floor_num] != NULL) { - phree(floorcache[floor_num]); + free(floorcache[floor_num]); } floorcache[floor_num] = fl; end_critical_section(S_FLOORCACHE); @@ -373,8 +373,8 @@ void putfloor(struct floor *flbuf, int floor_num) /* If we've cached this, clear it out, 'cuz it's WRONG now! */ begin_critical_section(S_FLOORCACHE); if (floorcache[floor_num] != NULL) { - phree(floorcache[floor_num]); - floorcache[floor_num] = mallok(sizeof(struct floor)); + free(floorcache[floor_num]); + floorcache[floor_num] = malloc(sizeof(struct floor)); memcpy(floorcache[floor_num], flbuf, sizeof(struct floor)); } end_critical_section(S_FLOORCACHE); @@ -805,7 +805,7 @@ void usergoto(char *where, int display_result, int transiently, get_mm(); cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -820,7 +820,7 @@ void usergoto(char *where, int display_result, int transiently, } } - if (msglist != NULL) phree(msglist); + if (msglist != NULL) free(msglist); if (CC->room.QRflags & QR_MAILBOX) rmailflag = 1; diff --git a/citadel/serv_calendar.c b/citadel/serv_calendar.c index beca84454..1b0d4876a 100644 --- a/citadel/serv_calendar.c +++ b/citadel/serv_calendar.c @@ -243,7 +243,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) { if (me_attend) icalproperty_free(me_attend); me_attend = icalproperty_new_clone(attendee); } - phree(recp); + free(recp); } } } @@ -302,11 +302,11 @@ void ical_send_a_reply(icalcomponent *request, char *action) { } /* Now generate the reply message and send it out. */ - serialized_reply = strdoop(icalcomponent_as_ical_string(the_reply)); + serialized_reply = strdup(icalcomponent_as_ical_string(the_reply)); icalcomponent_free(the_reply); /* don't need this anymore */ if (serialized_reply == NULL) return; - reply_message_text = mallok(strlen(serialized_reply) + SIZ); + reply_message_text = malloc(strlen(serialized_reply) + SIZ); if (reply_message_text != NULL) { sprintf(reply_message_text, "Content-type: text/calendar\r\n\r\n%s\r\n", @@ -325,7 +325,7 @@ void ical_send_a_reply(icalcomponent *request, char *action) { CtdlFreeMessage(msg); } } - phree(serialized_reply); + free(serialized_reply); } @@ -635,9 +635,9 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { * the event, this will work. */ template = (struct CtdlMessage *) - mallok(sizeof(struct CtdlMessage)); + malloc(sizeof(struct CtdlMessage)); memset(template, 0, sizeof(struct CtdlMessage)); - template->cm_fields['E'] = strdoop(uid); + template->cm_fields['E'] = strdup(uid); CtdlForEachMessage(MSGS_ALL, 0, "text/calendar", template, ical_hunt_for_event_to_update, &msgnum_being_replaced); CtdlFreeMessage(template); @@ -678,13 +678,13 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { ical_merge_attendee_reply(original_event, cal); /* Serialize it */ - serialized_event = strdoop(icalcomponent_as_ical_string(original_event)); + serialized_event = strdup(icalcomponent_as_ical_string(original_event)); icalcomponent_free(original_event); /* Don't need this anymore. */ if (serialized_event == NULL) return(2); MailboxName(roomname, sizeof roomname, &CC->user, USERCALENDARROOM); - message_text = mallok(strlen(serialized_event) + SIZ); + message_text = malloc(strlen(serialized_event) + SIZ); if (message_text != NULL) { sprintf(message_text, "Content-type: text/calendar\r\n\r\n%s\r\n", @@ -706,7 +706,7 @@ int ical_update_my_calendar_with_reply(icalcomponent *cal) { CIT_ICAL->avoid_sending_invitations = 0; } } - phree(serialized_event); + free(serialized_event); return(0); } @@ -1200,13 +1200,13 @@ void ical_freebusy(char *who) { /* Serialize it */ lprintf(CTDL_DEBUG, "Serializing\n"); - serialized_request = strdoop(icalcomponent_as_ical_string(encaps)); + serialized_request = strdup(icalcomponent_as_ical_string(encaps)); icalcomponent_free(encaps); /* Don't need this anymore. */ cprintf("%d Here is the free/busy data:\n", LISTING_FOLLOWS); if (serialized_request != NULL) { client_write(serialized_request, strlen(serialized_request)); - phree(serialized_request); + free(serialized_request); } cprintf("\n000\n"); @@ -1438,11 +1438,11 @@ void ical_send_out_invitations(icalcomponent *cal) { icalcomponent_add_component(encaps, the_request); /* Serialize it */ - serialized_request = strdoop(icalcomponent_as_ical_string(encaps)); + serialized_request = strdup(icalcomponent_as_ical_string(encaps)); icalcomponent_free(encaps); /* Don't need this anymore. */ if (serialized_request == NULL) return; - request_message_text = mallok(strlen(serialized_request) + SIZ); + request_message_text = malloc(strlen(serialized_request) + SIZ); if (request_message_text != NULL) { sprintf(request_message_text, "Content-type: text/calendar\r\n\r\n%s\r\n", @@ -1462,7 +1462,7 @@ void ical_send_out_invitations(icalcomponent *cal) { CtdlFreeMessage(msg); } } - phree(serialized_request); + free(serialized_request); } @@ -1633,21 +1633,21 @@ int ical_obj_beforesave(struct CtdlMessage *msg) ); if (strlen(imm.uid) > 0) { if (msg->cm_fields['E'] != NULL) { - phree(msg->cm_fields['E']); + free(msg->cm_fields['E']); } - msg->cm_fields['E'] = strdoop(imm.uid); + msg->cm_fields['E'] = strdup(imm.uid); } if (strlen(imm.subject) > 0) { if (msg->cm_fields['U'] != NULL) { - phree(msg->cm_fields['U']); + free(msg->cm_fields['U']); } - msg->cm_fields['U'] = strdoop(imm.subject); + msg->cm_fields['U'] = strdup(imm.subject); } if (imm.dtstart > 0) { if (msg->cm_fields['T'] != NULL) { - phree(msg->cm_fields['T']); + free(msg->cm_fields['T']); } - msg->cm_fields['T'] = strdoop("000000000000000000"); + msg->cm_fields['T'] = strdup("000000000000000000"); sprintf(msg->cm_fields['T'], "%ld", imm.dtstart); } return 0; diff --git a/citadel/serv_chat.c b/citadel/serv_chat.c index 2da4959d9..9baeaac74 100644 --- a/citadel/serv_chat.c +++ b/citadel/serv_chat.c @@ -82,7 +82,7 @@ void allwrite(char *cmdbuf, int flag, char *username) fprintf(fp, "%s\n", bcast); fclose(fp); } - clnew = (struct ChatLine *) mallok(sizeof(struct ChatLine)); + clnew = (struct ChatLine *) malloc(sizeof(struct ChatLine)); memset(clnew, 0, sizeof(struct ChatLine)); if (clnew == NULL) { fprintf(stderr, "citserver: cannot alloc chat line: %s\n", @@ -120,7 +120,7 @@ void allwrite(char *cmdbuf, int flag, char *username) while ((ChatQueue != NULL) && (now - ChatQueue->chat_time >= 120L)) { clptr = ChatQueue; ChatQueue = ChatQueue->next; - phree(clptr); + free(clptr); } end_critical_section(S_CHATQUEUE); } @@ -417,8 +417,8 @@ void delete_express_messages(void) { while (CC->FirstExpressMessage != NULL) { ptr = CC->FirstExpressMessage->next; if (CC->FirstExpressMessage->text != NULL) - phree(CC->FirstExpressMessage->text); - phree(CC->FirstExpressMessage); + free(CC->FirstExpressMessage->text); + free(CC->FirstExpressMessage); CC->FirstExpressMessage = ptr; } end_critical_section(S_SESSION_TABLE); @@ -458,8 +458,8 @@ void cmd_pexp(char *argbuf) memfmout(80, ptr->text, 0, "\n"); holdptr = ptr->next; - if (ptr->text != NULL) phree(ptr->text); - phree(ptr); + if (ptr->text != NULL) free(ptr->text); + free(ptr); ptr = holdptr; } cprintf("000\n"); @@ -492,10 +492,10 @@ void cmd_gexp(char *argbuf) { if (ptr->text != NULL) { memfmout(80, ptr->text, 0, "\n"); if (ptr->text[strlen(ptr->text)-1] != '\n') cprintf("\n"); - phree(ptr->text); + free(ptr->text); } cprintf("000\n"); - phree(ptr); + free(ptr); } /* @@ -577,7 +577,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg) || (CC->user.axlevel >= 6)) ) { if (do_send) { newmsg = (struct ExpressMessage *) - mallok(sizeof (struct ExpressMessage)); + malloc(sizeof (struct ExpressMessage)); memset(newmsg, 0, sizeof (struct ExpressMessage)); time(&(newmsg->timestamp)); @@ -585,7 +585,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg) sizeof newmsg->sender); if (!strcasecmp(x_user, "broadcast")) newmsg->flags |= EM_BROADCAST; - newmsg->text = strdoop(x_msg); + newmsg->text = strdup(x_msg); add_xmsg_to_context(ccptr, newmsg); @@ -608,16 +608,16 @@ int send_express_message(char *lun, char *x_user, char *x_msg) /* Log the page to disk if configured to do so */ if ( (do_send) && (message_sent) ) { - logmsg = mallok(sizeof(struct CtdlMessage)); + logmsg = malloc(sizeof(struct CtdlMessage)); memset(logmsg, 0, sizeof(struct CtdlMessage)); logmsg->cm_magic = CTDLMESSAGE_MAGIC; logmsg->cm_anon_type = MES_NORMAL; logmsg->cm_format_type = 0; - logmsg->cm_fields['A'] = strdoop(lun); - logmsg->cm_fields['N'] = strdoop(NODENAME); - logmsg->cm_fields['O'] = strdoop(PAGELOGROOM); - logmsg->cm_fields['R'] = strdoop(x_user); - logmsg->cm_fields['M'] = strdoop(x_msg); + logmsg->cm_fields['A'] = strdup(lun); + logmsg->cm_fields['N'] = strdup(NODENAME); + logmsg->cm_fields['O'] = strdup(PAGELOGROOM); + logmsg->cm_fields['R'] = strdup(x_user); + logmsg->cm_fields['M'] = strdup(x_msg); /* Save a copy of the message in the sender's log room, @@ -641,7 +641,7 @@ int send_express_message(char *lun, char *x_user, char *x_msg) create_room(sl->roomname, 5, "", 0, 1, 1); CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0); sptr = sl->next; - phree(sl); + free(sl); sl = sptr; } @@ -695,10 +695,10 @@ void cmd_sexp(char *argbuf) } cprintf("%d Transmit message (will deliver to %d users)\n", SEND_LISTING, message_sent); - x_big_msgbuf = mallok(SIZ); + x_big_msgbuf = malloc(SIZ); memset(x_big_msgbuf, 0, SIZ); while (client_gets(x_msg), strcmp(x_msg, "000")) { - x_big_msgbuf = reallok(x_big_msgbuf, + x_big_msgbuf = realloc(x_big_msgbuf, strlen(x_big_msgbuf) + strlen(x_msg) + 4); if (strlen(x_big_msgbuf) > 0) if (x_big_msgbuf[strlen(x_big_msgbuf)] != '\n') @@ -706,7 +706,7 @@ void cmd_sexp(char *argbuf) strcat(x_big_msgbuf, x_msg); } PerformXmsgHooks(lun, x_user, x_big_msgbuf); - phree(x_big_msgbuf); + free(x_big_msgbuf); /* This loop handles inline pages */ } else { @@ -767,14 +767,14 @@ void cmd_reqt(char *argbuf) { if ((ccptr->cs_pid == which_session) || (which_session == 0)) { newmsg = (struct ExpressMessage *) - mallok(sizeof (struct ExpressMessage)); + malloc(sizeof (struct ExpressMessage)); memset(newmsg, 0, sizeof (struct ExpressMessage)); time(&(newmsg->timestamp)); safestrncpy(newmsg->sender, CC->user.fullname, sizeof newmsg->sender); newmsg->flags |= EM_GO_AWAY; - newmsg->text = strdoop("Automatic logoff requested."); + newmsg->text = strdup("Automatic logoff requested."); add_xmsg_to_context(ccptr, newmsg); ++sessions; diff --git a/citadel/serv_crypto.c b/citadel/serv_crypto.c index b8d278a5e..a8aba6986 100644 --- a/citadel/serv_crypto.c +++ b/citadel/serv_crypto.c @@ -108,7 +108,7 @@ void init_ssl(void) return; } SSLCritters = - mallok(CRYPTO_num_locks() * sizeof(pthread_mutex_t *)); + malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t *)); if (!SSLCritters) { lprintf(CTDL_EMERG, "citserver: can't allocate memory!!\n"); /* Nothing's been initialized, just die */ @@ -117,7 +117,7 @@ void init_ssl(void) int a; for (a = 0; a < CRYPTO_num_locks(); a++) { - SSLCritters[a] = mallok(sizeof(pthread_mutex_t)); + SSLCritters[a] = malloc(sizeof(pthread_mutex_t)); if (!SSLCritters[a]) { lprintf(CTDL_EMERG, "citserver: can't allocate memory!!\n"); diff --git a/citadel/serv_expire.c b/citadel/serv_expire.c index 22013b3aa..083cb5d3c 100644 --- a/citadel/serv_expire.c +++ b/citadel/serv_expire.c @@ -140,7 +140,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) { cdbfr = cdb_fetch(CDB_MSGLISTS, &qrbuf->QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -148,7 +148,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) { /* Nothing to do if there aren't any messages */ if (num_msgs == 0) { - if (msglist != NULL) phree(msglist); + if (msglist != NULL) free(msglist); return; } @@ -183,7 +183,7 @@ void GatherPurgeMessages(struct ctdlroom *qrbuf, void *data) { } } - if (msglist != NULL) phree(msglist); + if (msglist != NULL) free(msglist); } @@ -235,7 +235,7 @@ void PurgeMessages(void) { void AddValidUser(struct ctdluser *usbuf, void *data) { struct ValidUser *vuptr; - vuptr = (struct ValidUser *)mallok(sizeof(struct ValidUser)); + vuptr = (struct ValidUser *)malloc(sizeof(struct ValidUser)); vuptr->next = ValidUserList; vuptr->vu_usernum = usbuf->usernum; ValidUserList = vuptr; @@ -244,7 +244,7 @@ void AddValidUser(struct ctdluser *usbuf, void *data) { void AddValidRoom(struct ctdlroom *qrbuf, void *data) { struct ValidRoom *vrptr; - vrptr = (struct ValidRoom *)mallok(sizeof(struct ValidRoom)); + vrptr = (struct ValidRoom *)malloc(sizeof(struct ValidRoom)); vrptr->next = ValidRoomList; vrptr->vr_roomnum = qrbuf->QRnumber; vrptr->vr_roomgen = qrbuf->QRgen; @@ -293,7 +293,7 @@ void DoPurgeRooms(struct ctdlroom *qrbuf, void *data) { } /* !QR_MAILBOX */ if (do_purge) { - pptr = (struct PurgeList *) mallok(sizeof(struct PurgeList)); + pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList)); pptr->next = RoomPurgeList; strcpy(pptr->name, qrbuf->QRname); RoomPurgeList = pptr; @@ -323,29 +323,29 @@ int PurgeRooms(void) { /* Free the valid user list */ while (ValidUserList != NULL) { vuptr = ValidUserList->next; - phree(ValidUserList); + free(ValidUserList); ValidUserList = vuptr; } - transcript = mallok(SIZ); + transcript = malloc(SIZ); strcpy(transcript, "The following rooms have been auto-purged:\n"); while (RoomPurgeList != NULL) { if (getroom(&qrbuf, RoomPurgeList->name) == 0) { - transcript=reallok(transcript, strlen(transcript)+SIZ); + transcript=realloc(transcript, strlen(transcript)+SIZ); snprintf(&transcript[strlen(transcript)], SIZ, " %s\n", qrbuf.QRname); delete_room(&qrbuf); } pptr = RoomPurgeList->next; - phree(RoomPurgeList); + free(RoomPurgeList); RoomPurgeList = pptr; ++num_rooms_purged; } if (num_rooms_purged > 0) aide_message(transcript); - phree(transcript); + free(transcript); lprintf(CTDL_DEBUG, "Purged %d rooms.\n", num_rooms_purged); return(num_rooms_purged); @@ -363,7 +363,7 @@ void do_uid_user_purge(struct ctdluser *us, void *data) { if ((us->uid != (-1)) && (us->uid != BBSUID)) { if (getpwuid(us->uid) == NULL) { pptr = (struct PurgeList *) - mallok(sizeof(struct PurgeList)); + malloc(sizeof(struct PurgeList)); pptr->next = UserPurgeList; strcpy(pptr->name, us->fullname); UserPurgeList = pptr; @@ -433,7 +433,7 @@ void do_user_purge(struct ctdluser *us, void *data) { if (us->timescalled == 0) purge = 1; if (purge == 1) { - pptr = (struct PurgeList *) mallok(sizeof(struct PurgeList)); + pptr = (struct PurgeList *) malloc(sizeof(struct PurgeList)); pptr->next = UserPurgeList; strcpy(pptr->name, us->fullname); UserPurgeList = pptr; @@ -454,22 +454,22 @@ int PurgeUsers(void) { } ForEachUser(do_uid_user_purge, NULL); - transcript = mallok(SIZ); + transcript = malloc(SIZ); strcpy(transcript, "The following users have been auto-purged:\n"); while (UserPurgeList != NULL) { - transcript=reallok(transcript, strlen(transcript)+SIZ); + transcript=realloc(transcript, strlen(transcript)+SIZ); snprintf(&transcript[strlen(transcript)], SIZ, " %s\n", UserPurgeList->name); purge_user(UserPurgeList->name); pptr = UserPurgeList->next; - phree(UserPurgeList); + free(UserPurgeList); UserPurgeList = pptr; ++num_users_purged; } if (num_users_purged > 0) aide_message(transcript); - phree(transcript); + free(transcript); lprintf(CTDL_DEBUG, "Purged %d users.\n", num_users_purged); return(num_users_purged); @@ -534,7 +534,7 @@ int PurgeVisits(void) { /* Put the record on the purge list if it's dead */ if ((RoomIsValid==0) || (UserIsValid==0)) { vptr = (struct VPurgeList *) - mallok(sizeof(struct VPurgeList)); + malloc(sizeof(struct VPurgeList)); vptr->next = VisitPurgeList; vptr->vp_roomnum = vbuf.v_roomnum; vptr->vp_roomgen = vbuf.v_roomgen; @@ -547,14 +547,14 @@ int PurgeVisits(void) { /* Free the valid room/gen combination list */ while (ValidRoomList != NULL) { vrptr = ValidRoomList->next; - phree(ValidRoomList); + free(ValidRoomList); ValidRoomList = vrptr; } /* Free the valid user list */ while (ValidUserList != NULL) { vuptr = ValidUserList->next; - phree(ValidUserList); + free(ValidUserList); ValidUserList = vuptr; } @@ -566,7 +566,7 @@ int PurgeVisits(void) { VisitPurgeList->vp_usernum); cdb_delete(CDB_VISIT, IndexBuf, IndexLen); vptr = VisitPurgeList->next; - phree(VisitPurgeList); + free(VisitPurgeList); VisitPurgeList = vptr; ++purged; } @@ -596,7 +596,7 @@ int PurgeUseTable(void) { cdb_free(cdbut); if ( (time(NULL) - ut.ut_timestamp) > USETABLE_RETAIN ) { - uptr = (struct UPurgeList *) mallok(sizeof(struct UPurgeList)); + uptr = (struct UPurgeList *) malloc(sizeof(struct UPurgeList)); if (uptr != NULL) { uptr->next = ul; safestrncpy(uptr->up_key, ut.ut_msgid, SIZ); @@ -612,7 +612,7 @@ int PurgeUseTable(void) { while (ul != NULL) { cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key)); uptr = ul->next; - phree(ul); + free(ul); ul = uptr; } @@ -664,7 +664,7 @@ void purge_databases(void) { void do_fsck_msg(long msgnum, void *userdata) { struct ctdlroomref *ptr; - ptr = (struct ctdlroomref *)mallok(sizeof(struct ctdlroomref)); + ptr = (struct ctdlroomref *)malloc(sizeof(struct ctdlroomref)); ptr->next = rr; ptr->msgnum = msgnum; rr = ptr; @@ -732,7 +732,7 @@ void cmd_fsck(char *argbuf) { cprintf("Freeing memory...\n"); while (rr != NULL) { ptr = rr->next; - phree(rr); + free(rr); rr = ptr; } diff --git a/citadel/serv_extensions.c b/citadel/serv_extensions.c index 78b60ea22..8d07fe6a3 100644 --- a/citadel/serv_extensions.c +++ b/citadel/serv_extensions.c @@ -50,7 +50,7 @@ void CtdlRegisterProtoHook(void (*handler) (char *), char *cmd, char *desc) struct ProtoFunctionHook *p; p = (struct ProtoFunctionHook *) - mallok(sizeof(struct ProtoFunctionHook)); + malloc(sizeof(struct ProtoFunctionHook)); if (p == NULL) { fprintf(stderr, "can't malloc new ProtoFunctionHook\n"); @@ -80,7 +80,7 @@ void CtdlUnregisterProtoHook(void (*handler) (char *), char *cmd) if (cur == ProtoHookList) { ProtoHookList = p; } - phree(cur); + free(cur); cur = p; } } @@ -133,7 +133,7 @@ void CtdlRegisterLogHook(void (*fcn_ptr) (char *), int loglevel) struct LogFunctionHook *newfcn; newfcn = (struct LogFunctionHook *) - mallok(sizeof(struct LogFunctionHook)); + malloc(sizeof(struct LogFunctionHook)); newfcn->next = LogHookTable; newfcn->h_function_pointer = fcn_ptr; newfcn->loglevel = loglevel; @@ -157,7 +157,7 @@ void CtdlUnregisterLogHook(void (*fcn_ptr) (char *), int loglevel) if (cur == LogHookTable) { LogHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -170,7 +170,7 @@ void CtdlRegisterCleanupHook(void (*fcn_ptr) (void)) struct CleanupFunctionHook *newfcn; newfcn = (struct CleanupFunctionHook *) - mallok(sizeof(struct CleanupFunctionHook)); + malloc(sizeof(struct CleanupFunctionHook)); newfcn->next = CleanupHookTable; newfcn->h_function_pointer = fcn_ptr; CleanupHookTable = newfcn; @@ -192,7 +192,7 @@ void CtdlUnregisterCleanupHook(void (*fcn_ptr) (void)) if (cur == CleanupHookTable) { CleanupHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -205,7 +205,7 @@ void CtdlRegisterSessionHook(void (*fcn_ptr) (void), int EventType) struct SessionFunctionHook *newfcn; newfcn = (struct SessionFunctionHook *) - mallok(sizeof(struct SessionFunctionHook)); + malloc(sizeof(struct SessionFunctionHook)); newfcn->next = SessionHookTable; newfcn->h_function_pointer = fcn_ptr; newfcn->eventtype = EventType; @@ -231,7 +231,7 @@ void CtdlUnregisterSessionHook(void (*fcn_ptr) (void), int EventType) if (cur == SessionHookTable) { SessionHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -244,7 +244,7 @@ void CtdlRegisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType) struct UserFunctionHook *newfcn; newfcn = (struct UserFunctionHook *) - mallok(sizeof(struct UserFunctionHook)); + malloc(sizeof(struct UserFunctionHook)); newfcn->next = UserHookTable; newfcn->h_function_pointer = fcn_ptr; newfcn->eventtype = EventType; @@ -270,7 +270,7 @@ void CtdlUnregisterUserHook(void (*fcn_ptr) (struct ctdluser *), int EventType) if (cur == UserHookTable) { UserHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -284,7 +284,7 @@ void CtdlRegisterMessageHook(int (*handler)(struct CtdlMessage *), struct MessageFunctionHook *newfcn; newfcn = (struct MessageFunctionHook *) - mallok(sizeof(struct MessageFunctionHook)); + malloc(sizeof(struct MessageFunctionHook)); newfcn->next = MessageHookTable; newfcn->h_function_pointer = handler; newfcn->eventtype = EventType; @@ -311,7 +311,7 @@ void CtdlUnregisterMessageHook(int (*handler)(struct CtdlMessage *), if (cur == MessageHookTable) { MessageHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -323,7 +323,7 @@ void CtdlRegisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ) struct NetprocFunctionHook *newfcn; newfcn = (struct NetprocFunctionHook *) - mallok(sizeof(struct NetprocFunctionHook)); + malloc(sizeof(struct NetprocFunctionHook)); newfcn->next = NetprocHookTable; newfcn->h_function_pointer = handler; NetprocHookTable = newfcn; @@ -345,7 +345,7 @@ void CtdlUnregisterNetprocHook(int (*handler)(struct CtdlMessage *, char *) ) if (cur == NetprocHookTable) { NetprocHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -357,7 +357,7 @@ void CtdlRegisterDeleteHook(void (*handler)(char *, long) ) struct DeleteFunctionHook *newfcn; newfcn = (struct DeleteFunctionHook *) - mallok(sizeof(struct DeleteFunctionHook)); + malloc(sizeof(struct DeleteFunctionHook)); newfcn->next = DeleteHookTable; newfcn->h_function_pointer = handler; DeleteHookTable = newfcn; @@ -379,7 +379,7 @@ void CtdlUnregisterDeleteHook(void (*handler)(char *, long) ) if (cur == DeleteHookTable) { DeleteHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -392,7 +392,7 @@ void CtdlRegisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order) struct XmsgFunctionHook *newfcn; newfcn = (struct XmsgFunctionHook *) - mallok(sizeof(struct XmsgFunctionHook)); + malloc(sizeof(struct XmsgFunctionHook)); newfcn->next = XmsgHookTable; newfcn->order = order; newfcn->h_function_pointer = fcn_ptr; @@ -416,7 +416,7 @@ void CtdlUnregisterXmsgHook(int (*fcn_ptr) (char *, char *, char *), int order) if (cur == XmsgHookTable) { XmsgHookTable = p; } - phree(cur); + free(cur); cur = p; } } @@ -432,7 +432,7 @@ void CtdlRegisterServiceHook(int tcp_port, char message[SIZ]; newfcn = (struct ServiceFunctionHook *) - mallok(sizeof(struct ServiceFunctionHook)); + malloc(sizeof(struct ServiceFunctionHook)); newfcn->next = ServiceHookTable; newfcn->tcp_port = tcp_port; newfcn->sockpath = sockpath; @@ -445,7 +445,7 @@ void CtdlRegisterServiceHook(int tcp_port, } else if (tcp_port <= 0) { /* port -1 to disable */ lprintf(CTDL_INFO, "Service has been manually disabled, skipping\n"); - phree(newfcn); + free(newfcn); return; } else { @@ -461,7 +461,7 @@ void CtdlRegisterServiceHook(int tcp_port, else { strcat(message, "FAILED."); lprintf(CTDL_CRIT, "%s\n", message); - phree(newfcn); + free(newfcn); } } @@ -493,7 +493,7 @@ void CtdlUnregisterServiceHook(int tcp_port, char *sockpath, if (cur == ServiceHookTable) { ServiceHookTable = p; } - phree(cur); + free(cur); cur = p; } } diff --git a/citadel/serv_imap.c b/citadel/serv_imap.c index 03831e454..bee2dedb1 100644 --- a/citadel/serv_imap.c +++ b/citadel/serv_imap.c @@ -81,12 +81,12 @@ struct irlparms { void imap_free_msgids(void) { if (IMAP->msgids != NULL) { - phree(IMAP->msgids); + free(IMAP->msgids); IMAP->msgids = NULL; IMAP->num_msgs = 0; } if (IMAP->flags != NULL) { - phree(IMAP->flags); + free(IMAP->flags); IMAP->flags = NULL; } } @@ -98,7 +98,7 @@ void imap_free_msgids(void) void imap_free_transmitted_message(void) { if (IMAP->transmitted_message != NULL) { - phree(IMAP->transmitted_message); + free(IMAP->transmitted_message); IMAP->transmitted_message = NULL; IMAP->transmitted_length = 0; } @@ -142,18 +142,18 @@ void imap_add_single_msgid(long msgnum, void *userdata) IMAP->num_msgs = IMAP->num_msgs + 1; if (IMAP->msgids == NULL) { - IMAP->msgids = mallok(IMAP->num_msgs * sizeof(long) + IMAP->msgids = malloc(IMAP->num_msgs * sizeof(long) * REALLOC_INCREMENT); } else if (IMAP->num_msgs % REALLOC_INCREMENT == 0) { - IMAP->msgids = reallok(IMAP->msgids, + IMAP->msgids = realloc(IMAP->msgids, (IMAP->num_msgs + REALLOC_INCREMENT) * sizeof(long)); } if (IMAP->flags == NULL) { - IMAP->flags = mallok(IMAP->num_msgs * sizeof(long) + IMAP->flags = malloc(IMAP->num_msgs * sizeof(long) * REALLOC_INCREMENT); } else if (IMAP->num_msgs % REALLOC_INCREMENT == 0) { - IMAP->flags = reallok(IMAP->flags, + IMAP->flags = realloc(IMAP->flags, (IMAP->num_msgs + REALLOC_INCREMENT) * sizeof(long)); } @@ -212,7 +212,7 @@ void imap_rescan_msgids(void) */ cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -285,7 +285,7 @@ void imap_rescan_msgids(void) } if (num_msgs != 0) - phree(msglist); + free(msglist); } @@ -1121,7 +1121,7 @@ void imap_rename_backend(struct ctdlroom *qrbuf, void *data) sizeof newroomname, newfoldername) & 0xFF; - irlp = (struct irl *) mallok(sizeof(struct irl)); + irlp = (struct irl *) malloc(sizeof(struct irl)); strcpy(irlp->irl_newroom, newroomname); strcpy(irlp->irl_oldroom, qrbuf->QRname); irlp->irl_newfloor = newfloor; @@ -1214,7 +1214,7 @@ void imap_rename(int num_parms, char *parms[]) } irlp = irl; irl = irl->next; - phree(irlp); + free(irlp); } } diff --git a/citadel/serv_inetcfg.c b/citadel/serv_inetcfg.c index 737a84da3..877b2fb2c 100644 --- a/citadel/serv_inetcfg.c +++ b/citadel/serv_inetcfg.c @@ -57,7 +57,7 @@ void inetcfg_setTo(struct CtdlMessage *msg) { char buf[SIZ]; if (msg->cm_fields['M']==NULL) return; - conf = strdoop(msg->cm_fields['M']); + conf = strdup(msg->cm_fields['M']); if (conf != NULL) { do { @@ -65,7 +65,7 @@ void inetcfg_setTo(struct CtdlMessage *msg) { strcpy(conf, &conf[strlen(buf)+1]); } while ( (strlen(conf)>0) && (strlen(buf)>0) ); - if (inetcfg != NULL) phree(inetcfg); + if (inetcfg != NULL) free(inetcfg); inetcfg = conf; } } @@ -82,20 +82,20 @@ void spamstrings_setTo(struct CtdlMessage *msg) { while (spamstrings != NULL) { sptr = spamstrings; spamstrings = spamstrings->next; - phree(sptr->string); - phree(sptr); + free(sptr->string); + free(sptr); } /* Read in the new list */ if (msg->cm_fields['M']==NULL) return; - conf = strdoop(msg->cm_fields['M']); + conf = strdup(msg->cm_fields['M']); if (conf == NULL) return; n = num_tokens(conf, '\n'); for (i=0; istring = strdoop(buf); + sptr = malloc(sizeof(struct spamstrings_t)); + sptr->string = strdup(buf); sptr->next = spamstrings; spamstrings = sptr; } diff --git a/citadel/serv_ldap.c b/citadel/serv_ldap.c index c4ff284e1..6b15584e0 100644 --- a/citadel/serv_ldap.c +++ b/citadel/serv_ldap.c @@ -274,13 +274,13 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { * with Kolab. */ num_attrs = 1; - attrs = mallok( (sizeof(LDAPMod *) * num_attrs) ); - attrs[0] = mallok(sizeof(LDAPMod)); + attrs = malloc( (sizeof(LDAPMod *) * num_attrs) ); + attrs[0] = malloc(sizeof(LDAPMod)); memset(attrs[0], 0, sizeof(LDAPMod)); attrs[0]->mod_op = LDAP_MOD_ADD; attrs[0]->mod_type = "objectclass"; - attrs[0]->mod_values = mallok(3 * sizeof(char *)); - attrs[0]->mod_values[0] = strdoop("inetOrgPerson"); + attrs[0]->mod_values = malloc(3 * sizeof(char *)); + attrs[0]->mod_values[0] = strdup("inetOrgPerson"); attrs[0]->mod_values[1] = NULL; /* Convert the vCard fields to LDAP properties */ @@ -293,36 +293,36 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { } if (!strcasecmp(v->prop[i].name, "fn")) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "cn"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(v->prop[i].value); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(v->prop[i].value); attrs[num_attrs-1]->mod_values[1] = NULL; have_cn = 1; } if (!strcasecmp(v->prop[i].name, "title")) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "title"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(v->prop[i].value); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(v->prop[i].value); attrs[num_attrs-1]->mod_values[1] = NULL; } if (!strcasecmp(v->prop[i].name, "org")) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "o"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(v->prop[i].value); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(v->prop[i].value); attrs[num_attrs-1]->mod_values[1] = NULL; } @@ -345,40 +345,40 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { extract_token(state, v->prop[i].value, 4, ';'); extract_token(zipcode, v->prop[i].value, 5, ';'); - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "street"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(street); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(street); attrs[num_attrs-1]->mod_values[1] = NULL; - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "l"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(city); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(city); attrs[num_attrs-1]->mod_values[1] = NULL; - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "st"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(state); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(state); attrs[num_attrs-1]->mod_values[1] = NULL; - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "postalcode"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(zipcode); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(zipcode); attrs[num_attrs-1]->mod_values[1] = NULL; } } @@ -388,22 +388,22 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { ++num_phones; /* The first 'tel' property creates the 'telephoneNumber' attribute */ if (num_phones == 1) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); phone_attr = num_attrs-1; - attrs[phone_attr] = mallok(sizeof(LDAPMod)); + attrs[phone_attr] = malloc(sizeof(LDAPMod)); memset(attrs[phone_attr], 0, sizeof(LDAPMod)); attrs[phone_attr]->mod_op = LDAP_MOD_ADD; attrs[phone_attr]->mod_type = "telephoneNumber"; - attrs[phone_attr]->mod_values = mallok(2 * sizeof(char *)); - attrs[phone_attr]->mod_values[0] = strdoop(v->prop[i].value); + attrs[phone_attr]->mod_values = malloc(2 * sizeof(char *)); + attrs[phone_attr]->mod_values[0] = strdup(v->prop[i].value); attrs[phone_attr]->mod_values[1] = NULL; } /* Subsequent 'tel' properties *add to* the 'telephoneNumber' attribute */ else { - attrs[phone_attr]->mod_values = reallok(attrs[phone_attr]->mod_values, + attrs[phone_attr]->mod_values = realloc(attrs[phone_attr]->mod_values, num_phones * sizeof(char *)); attrs[phone_attr]->mod_values[num_phones-1] - = strdoop(v->prop[i].value); + = strdup(v->prop[i].value); attrs[phone_attr]->mod_values[num_phones] = NULL; } @@ -418,33 +418,33 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { /* The first email address creates the 'mail' attribute */ if (num_emails == 1) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "mail"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(v->prop[i].value); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(v->prop[i].value); attrs[num_attrs-1]->mod_values[1] = NULL; } /* The second email address creates the 'alias' attribute */ else if (num_emails == 2) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); alias_attr = num_attrs-1; - attrs[alias_attr] = mallok(sizeof(LDAPMod)); + attrs[alias_attr] = malloc(sizeof(LDAPMod)); memset(attrs[alias_attr], 0, sizeof(LDAPMod)); attrs[alias_attr]->mod_op = LDAP_MOD_ADD; attrs[alias_attr]->mod_type = "alias"; - attrs[alias_attr]->mod_values = mallok(2 * sizeof(char *)); - attrs[alias_attr]->mod_values[0] = strdoop(v->prop[i].value); + attrs[alias_attr]->mod_values = malloc(2 * sizeof(char *)); + attrs[alias_attr]->mod_values[0] = strdup(v->prop[i].value); attrs[alias_attr]->mod_values[1] = NULL; } /* Subsequent email addresses *add to* the 'alias' attribute */ else if (num_emails > 2) { - attrs[alias_attr]->mod_values = reallok(attrs[alias_attr]->mod_values, + attrs[alias_attr]->mod_values = realloc(attrs[alias_attr]->mod_values, num_emails * sizeof(char *)); attrs[alias_attr]->mod_values[num_emails-2] - = strdoop(v->prop[i].value); + = strdup(v->prop[i].value); attrs[alias_attr]->mod_values[num_emails-1] = NULL; } @@ -456,48 +456,48 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { vcard_free(v); /* Don't need this anymore. */ /* "sn" (surname) based on info in vCard */ - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "sn"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(sn); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(sn); attrs[num_attrs-1]->mod_values[1] = NULL; /* "givenname" (first name) based on info in vCard */ if (strlen(givenname) == 0) strcpy(givenname, "_"); if (strlen(sn) == 0) strcpy(sn, "_"); - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "givenname"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(givenname); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(givenname); attrs[num_attrs-1]->mod_values[1] = NULL; /* "uid" is a Kolab compatibility thing. We just do cituser@citnode */ - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "uid"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(uid); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(uid); attrs[num_attrs-1]->mod_values[1] = NULL; /* Add a "cn" (Common Name) attribute based on the user's screen name, * but only there was no 'fn' (full name) property in the vCard */ if (!have_cn) { - attrs = reallok(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); - attrs[num_attrs-1] = mallok(sizeof(LDAPMod)); + attrs = realloc(attrs, (sizeof(LDAPMod *) * ++num_attrs) ); + attrs[num_attrs-1] = malloc(sizeof(LDAPMod)); memset(attrs[num_attrs-1], 0, sizeof(LDAPMod)); attrs[num_attrs-1]->mod_op = LDAP_MOD_ADD; attrs[num_attrs-1]->mod_type = "cn"; - attrs[num_attrs-1]->mod_values = mallok(2 * sizeof(char *)); - attrs[num_attrs-1]->mod_values[0] = strdoop(msg->cm_fields['A']); + attrs[num_attrs-1]->mod_values = malloc(2 * sizeof(char *)); + attrs[num_attrs-1]->mod_values[0] = strdup(msg->cm_fields['A']); attrs[num_attrs-1]->mod_values[1] = NULL; } @@ -534,20 +534,20 @@ void ctdl_vcard_to_ldap(struct CtdlMessage *msg, int op) { /* First, free the value strings */ if (attrs[i]->mod_values != NULL) { for (j=0; attrs[i]->mod_values[j] != NULL; ++j) { - phree(attrs[i]->mod_values[j]); + free(attrs[i]->mod_values[j]); } } /* Free the value strings pointer list */ if (attrs[i]->mod_values != NULL) { - phree(attrs[i]->mod_values); + free(attrs[i]->mod_values); } /* Now free the LDAPMod struct itself. */ - phree(attrs[i]); + free(attrs[i]); } } - phree(attrs); + free(attrs); lprintf(CTDL_DEBUG, "LDAP write operation complete.\n"); } diff --git a/citadel/serv_listsub.c b/citadel/serv_listsub.c index 2138fda19..e7481d139 100644 --- a/citadel/serv_listsub.c +++ b/citadel/serv_listsub.c @@ -395,7 +395,7 @@ void do_confirm(char *room, char *token) { * that address. */ if (strlen(address_to_unsubscribe) > 0) { - holdbuf = mallok(SIZ); + holdbuf = malloc(SIZ); begin_critical_section(S_NETCONFIGS); ncfp = fopen(filename, "r+"); if (ncfp != NULL) { @@ -426,7 +426,7 @@ void do_confirm(char *room, char *token) { } else { /* Not relevant, so *keep* it! */ linelen = strlen(buf); - holdbuf = reallok(holdbuf, + holdbuf = realloc(holdbuf, (buflen + linelen + 2) ); strcpy(&holdbuf[buflen], buf); buflen += linelen; @@ -442,7 +442,7 @@ void do_confirm(char *room, char *token) { fclose(ncfp); } end_critical_section(S_NETCONFIGS); - phree(holdbuf); + free(holdbuf); } /* diff --git a/citadel/serv_network.c b/citadel/serv_network.c index df12c6bcd..9daa976a8 100644 --- a/citadel/serv_network.c +++ b/citadel/serv_network.c @@ -103,7 +103,7 @@ struct FilterList *load_filter_list(void) { /* Use the string tokenizer to grab one line at a time */ for (i=0; ifl_user, buf, 0); striplt(nptr->fl_user); extract(nptr->fl_room, buf, 1); @@ -116,7 +116,7 @@ struct FilterList *load_filter_list(void) { */ if (strlen(nptr->fl_user) + strlen(nptr->fl_room) + strlen(nptr->fl_node) == 0) { - phree(nptr); + free(nptr); } else { nptr->next = newlist; @@ -124,7 +124,7 @@ struct FilterList *load_filter_list(void) { } } - phree(serialized_list); + free(serialized_list); return newlist; } @@ -132,7 +132,7 @@ struct FilterList *load_filter_list(void) { void free_filter_list(struct FilterList *fl) { if (fl == NULL) return; free_filter_list(fl->next); - phree(fl); + free(fl); } @@ -202,7 +202,7 @@ void read_network_map(void) { /* Use the string tokenizer to grab one line at a time */ for (i=0; inodename, buf, 0); nmptr->lastcontact = extract_long(buf, 1); extract(nmptr->nexthop, buf, 2); @@ -210,7 +210,7 @@ void read_network_map(void) { the_netmap = nmptr; } - phree(serialized_map); + free(serialized_map); } @@ -221,11 +221,11 @@ void write_network_map(void) { char *serialized_map = NULL; struct NetMap *nmptr; - serialized_map = strdoop(""); + serialized_map = strdup(""); if (the_netmap != NULL) { for (nmptr = the_netmap; nmptr != NULL; nmptr = nmptr->next) { - serialized_map = reallok(serialized_map, + serialized_map = realloc(serialized_map, (strlen(serialized_map)+SIZ) ); if (strlen(nmptr->nodename) > 0) { snprintf(&serialized_map[strlen(serialized_map)], @@ -239,12 +239,12 @@ void write_network_map(void) { } CtdlPutSysConfig(IGNETMAP, serialized_map); - phree(serialized_map); + free(serialized_map); /* Now free the list */ while (the_netmap != NULL) { nmptr = the_netmap->next; - phree(the_netmap); + free(the_netmap); the_netmap = nmptr; } } @@ -430,7 +430,7 @@ void network_spool_msg(long msgnum, void *userdata) { * allocate... */ lprintf(CTDL_DEBUG, "Generating delivery instructions\n"); - instr = mallok(instr_len); + instr = malloc(instr_len); if (instr == NULL) { lprintf(CTDL_EMERG, "Cannot allocate %ld bytes for instr...\n", (long)instr_len); @@ -451,12 +451,12 @@ void network_spool_msg(long msgnum, void *userdata) { /* * Generate a message from the instructions */ - imsg = mallok(sizeof(struct CtdlMessage)); + imsg = malloc(sizeof(struct CtdlMessage)); memset(imsg, 0, sizeof(struct CtdlMessage)); imsg->cm_magic = CTDLMESSAGE_MAGIC; imsg->cm_anon_type = MES_NORMAL; imsg->cm_format_type = FMT_RFC822; - imsg->cm_fields['A'] = strdoop("Citadel"); + imsg->cm_fields['A'] = strdup("Citadel"); imsg->cm_fields['M'] = instr; /* Save delivery instructions in spoolout room */ @@ -490,14 +490,14 @@ void network_spool_msg(long msgnum, void *userdata) { * sending a message to another IGnet node */ if (msg->cm_fields['P'] == NULL) { - msg->cm_fields['P'] = strdoop("username"); + msg->cm_fields['P'] = strdup("username"); } newpath_len = strlen(msg->cm_fields['P']) + strlen(config.c_nodename) + 2; - newpath = mallok(newpath_len); + newpath = malloc(newpath_len); snprintf(newpath, newpath_len, "%s!%s", config.c_nodename, msg->cm_fields['P']); - phree(msg->cm_fields['P']); + free(msg->cm_fields['P']); msg->cm_fields['P'] = newpath; /* @@ -505,9 +505,9 @@ void network_spool_msg(long msgnum, void *userdata) { * on the far end by setting the C field correctly */ if (msg->cm_fields['C'] != NULL) { - phree(msg->cm_fields['C']); + free(msg->cm_fields['C']); } - msg->cm_fields['C'] = strdoop(CC->room.QRname); + msg->cm_fields['C'] = strdup(CC->room.QRname); /* * Determine if this message is set to be deleted @@ -562,7 +562,7 @@ void network_spool_msg(long msgnum, void *userdata) { } } } - phree(sermsg.ser); + free(sermsg.ser); CtdlFreeMessage(msg); } } @@ -598,27 +598,27 @@ void network_deliver_digest(struct SpoolControl *sc) { return; } - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_format_type = FMT_RFC822; msg->cm_anon_type = MES_NORMAL; sprintf(buf, "%ld", time(NULL)); - msg->cm_fields['T'] = strdoop(buf); - msg->cm_fields['A'] = strdoop(CC->room.QRname); - msg->cm_fields['U'] = strdoop(CC->room.QRname); + msg->cm_fields['T'] = strdup(buf); + msg->cm_fields['A'] = strdup(CC->room.QRname); + msg->cm_fields['U'] = strdup(CC->room.QRname); sprintf(buf, "room_%s@%s", CC->room.QRname, config.c_fqdn); for (i=0; icm_fields['F'] = strdoop(buf); + msg->cm_fields['F'] = strdup(buf); fseek(sc->digestfp, 0L, SEEK_END); msglen = ftell(sc->digestfp); - msg->cm_fields['M'] = mallok(msglen + 1); + msg->cm_fields['M'] = malloc(msglen + 1); fseek(sc->digestfp, 0L, SEEK_SET); fread(msg->cm_fields['M'], (size_t)msglen, 1, sc->digestfp); msg->cm_fields['M'][msglen] = 0; @@ -642,7 +642,7 @@ void network_deliver_digest(struct SpoolControl *sc) { * allocate... */ lprintf(CTDL_DEBUG, "Generating delivery instructions\n"); - instr = mallok(instr_len); + instr = malloc(instr_len); if (instr == NULL) { lprintf(CTDL_EMERG, "Cannot allocate %ld bytes for instr...\n", (long)instr_len); @@ -663,12 +663,12 @@ void network_deliver_digest(struct SpoolControl *sc) { /* * Generate a message from the instructions */ - imsg = mallok(sizeof(struct CtdlMessage)); + imsg = malloc(sizeof(struct CtdlMessage)); memset(imsg, 0, sizeof(struct CtdlMessage)); imsg->cm_magic = CTDLMESSAGE_MAGIC; imsg->cm_anon_type = MES_NORMAL; imsg->cm_format_type = FMT_RFC822; - imsg->cm_fields['A'] = strdoop("Citadel"); + imsg->cm_fields['A'] = strdup("Citadel"); imsg->cm_fields['M'] = instr; /* Save delivery instructions in spoolout room */ @@ -720,21 +720,21 @@ void network_spoolout_room(char *room_to_spool) { } else if (!strcasecmp(instr, "listrecp")) { nptr = (struct namelist *) - mallok(sizeof(struct namelist)); + malloc(sizeof(struct namelist)); nptr->next = sc.listrecps; extract(nptr->name, buf, 1); sc.listrecps = nptr; } else if (!strcasecmp(instr, "digestrecp")) { nptr = (struct namelist *) - mallok(sizeof(struct namelist)); + malloc(sizeof(struct namelist)); nptr->next = sc.digestrecps; extract(nptr->name, buf, 1); sc.digestrecps = nptr; } else if (!strcasecmp(instr, "ignet_push_share")) { nptr = (struct namelist *) - mallok(sizeof(struct namelist)); + malloc(sizeof(struct namelist)); nptr->next = sc.ignet_push_shares; extract(nptr->name, buf, 1); sc.ignet_push_shares = nptr; @@ -813,14 +813,14 @@ void network_spoolout_room(char *room_to_spool) { while (sc.listrecps != NULL) { fprintf(fp, "listrecp|%s\n", sc.listrecps->name); nptr = sc.listrecps->next; - phree(sc.listrecps); + free(sc.listrecps); sc.listrecps = nptr; } /* Do the same for digestrecps */ while (sc.digestrecps != NULL) { fprintf(fp, "digestrecp|%s\n", sc.digestrecps->name); nptr = sc.digestrecps->next; - phree(sc.digestrecps); + free(sc.digestrecps); sc.digestrecps = nptr; } while (sc.ignet_push_shares != NULL) { @@ -833,13 +833,13 @@ void network_spoolout_room(char *room_to_spool) { sc.ignet_push_shares->name); } nptr = sc.ignet_push_shares->next; - phree(sc.ignet_push_shares); + free(sc.ignet_push_shares); sc.ignet_push_shares = nptr; } if (sc.misc != NULL) { fwrite(sc.misc, strlen(sc.misc), 1, fp); } - phree(sc.misc); + free(sc.misc); fclose(fp); } @@ -860,7 +860,7 @@ int network_sync_to(char *target_node) { /* Concise syntax because we don't need a full linked-list */ memset(&sc, 0, sizeof(struct SpoolControl)); sc.ignet_push_shares = (struct namelist *) - mallok(sizeof(struct namelist)); + malloc(sizeof(struct namelist)); sc.ignet_push_shares->next = NULL; safestrncpy(sc.ignet_push_shares->name, target_node, @@ -871,7 +871,7 @@ int network_sync_to(char *target_node) { network_spool_msg, &sc); /* Concise cleanup because we know there's only one node in the sc */ - phree(sc.ignet_push_shares); + free(sc.ignet_push_shares); lprintf(CTDL_INFO, "Synchronized %d messages to <%s>\n", num_spooled, target_node); @@ -901,7 +901,7 @@ void cmd_nsyn(char *argbuf) { void network_queue_room(struct ctdlroom *qrbuf, void *data) { struct RoomProcList *ptr; - ptr = (struct RoomProcList *) mallok(sizeof (struct RoomProcList)); + ptr = (struct RoomProcList *) malloc(sizeof (struct RoomProcList)); if (ptr == NULL) return; safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name); @@ -929,7 +929,7 @@ void network_learn_topology(char *node, char *path) { } /* If we got here then it's not in the map, so add it. */ - nmptr = (struct NetMap *) mallok(sizeof (struct NetMap)); + nmptr = (struct NetMap *) malloc(sizeof (struct NetMap)); strcpy(nmptr->nodename, node); nmptr->lastcontact = time(NULL); extract_token(nmptr->nexthop, path, 0, '!'); @@ -963,46 +963,46 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { * Give it a fresh message ID */ if (msg->cm_fields['I'] != NULL) { - phree(msg->cm_fields['I']); + free(msg->cm_fields['I']); } snprintf(buf, sizeof buf, "%ld.%04lx.%04x@%s", (long)time(NULL), (long)getpid(), ++serialnum, config.c_fqdn); - msg->cm_fields['I'] = strdoop(buf); + msg->cm_fields['I'] = strdup(buf); /* * FIXME ... right now we're just sending a bounce; we really want to * include the text of the bounced message. */ if (msg->cm_fields['M'] != NULL) { - phree(msg->cm_fields['M']); + free(msg->cm_fields['M']); } - msg->cm_fields['M'] = strdoop(reason); + msg->cm_fields['M'] = strdup(reason); msg->cm_format_type = 0; /* * Turn the message around */ if (msg->cm_fields['R'] == NULL) { - phree(msg->cm_fields['R']); + free(msg->cm_fields['R']); } if (msg->cm_fields['D'] == NULL) { - phree(msg->cm_fields['D']); + free(msg->cm_fields['D']); } snprintf(recipient, sizeof recipient, "%s@%s", msg->cm_fields['A'], msg->cm_fields['N']); if (msg->cm_fields['A'] == NULL) { - phree(msg->cm_fields['A']); + free(msg->cm_fields['A']); } if (msg->cm_fields['N'] == NULL) { - phree(msg->cm_fields['N']); + free(msg->cm_fields['N']); } - msg->cm_fields['A'] = strdoop(BOUNCESOURCE); - msg->cm_fields['N'] = strdoop(config.c_nodename); + msg->cm_fields['A'] = strdup(BOUNCESOURCE); + msg->cm_fields['N'] = strdup(config.c_nodename); /* prepend our node to the path */ @@ -1011,17 +1011,17 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { msg->cm_fields['P'] = NULL; } else { - oldpath = strdoop("unknown_user"); + oldpath = strdup("unknown_user"); } size = strlen(oldpath) + SIZ; - msg->cm_fields['P'] = mallok(size); + msg->cm_fields['P'] = malloc(size); snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath); - phree(oldpath); + free(oldpath); /* Now submit the message */ valid = validate_recipients(recipient); if (valid != NULL) if (valid->num_error > 0) { - phree(valid); + free(valid); valid = NULL; } if ( (valid == NULL) || (!strcasecmp(recipient, bouncesource)) ) { @@ -1036,7 +1036,7 @@ void network_bounce(struct CtdlMessage *msg, char *reason) { CtdlSubmitMsg(msg, valid, force_room); /* Clean up */ - if (valid != NULL) phree(valid); + if (valid != NULL) free(valid); CtdlFreeMessage(msg); lprintf(CTDL_DEBUG, "leaving network_bounce()\n"); } @@ -1076,7 +1076,7 @@ void network_process_buffer(char *buffer, long size) { strcpy(target_room, TWITROOM); /* Load the message into memory */ - msg = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage)); + msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = buffer[1]; @@ -1084,7 +1084,7 @@ void network_process_buffer(char *buffer, long size) { for (pos = 3; pos < size; ++pos) { field = buffer[pos]; - msg->cm_fields[field] = strdoop(&buffer[pos+1]); + msg->cm_fields[field] = strdup(&buffer[pos+1]); pos = pos + strlen(&buffer[(int)pos]); } @@ -1103,13 +1103,13 @@ void network_process_buffer(char *buffer, long size) { msg->cm_fields['P'] = NULL; } else { - oldpath = strdoop("unknown_user"); + oldpath = strdup("unknown_user"); } size = strlen(oldpath) + SIZ; - msg->cm_fields['P'] = mallok(size); + msg->cm_fields['P'] = malloc(size); snprintf(msg->cm_fields['P'], size, "%s!%s", config.c_nodename, oldpath); - phree(oldpath); + free(oldpath); /* serialize the message */ serialize_message(&sermsg, msg); @@ -1126,7 +1126,7 @@ void network_process_buffer(char *buffer, long size) { sermsg.len, 1, fp); fclose(fp); } - phree(sermsg.ser); + free(sermsg.ser); CtdlFreeMessage(msg); return; } @@ -1167,7 +1167,7 @@ void network_process_buffer(char *buffer, long size) { "A message you sent could not be delivered due to an invalid address.\n" "Please check the address and try sending the message again.\n"); msg = NULL; - phree(recp); + free(recp); return; } strcpy(target_room, ""); /* no target room if mail */ @@ -1187,11 +1187,11 @@ void network_process_buffer(char *buffer, long size) { /* Strip out fields that are only relevant during transit */ if (msg->cm_fields['D'] != NULL) { - phree(msg->cm_fields['D']); + free(msg->cm_fields['D']); msg->cm_fields['D'] = NULL; } if (msg->cm_fields['C'] != NULL) { - phree(msg->cm_fields['C']); + free(msg->cm_fields['C']); msg->cm_fields['C'] = NULL; } @@ -1201,7 +1201,7 @@ void network_process_buffer(char *buffer, long size) { CtdlSubmitMsg(msg, recp, target_room); } CtdlFreeMessage(msg); - phree(recp); + free(recp); } @@ -1215,12 +1215,12 @@ void network_process_message(FILE *fp, long msgstart, long msgend) { hold_pos = ftell(fp); size = msgend - msgstart + 1; - buffer = mallok(size); + buffer = malloc(size); if (buffer != NULL) { fseek(fp, msgstart, SEEK_SET); fread(buffer, size, 1, fp); network_process_buffer(buffer, size); - phree(buffer); + free(buffer); } fseek(fp, hold_pos, SEEK_SET); @@ -1614,7 +1614,7 @@ void network_do_queue(void) { network_spoolout_room(rplist->name); ptr = rplist; rplist = rplist->next; - phree(ptr); + free(ptr); } } @@ -1705,7 +1705,7 @@ int netconfig_aftersave(struct CtdlMessage *msg) { if (!strncasecmp(ptr, "Content-type: ", 14)) { if (!strncasecmp(&ptr[14], IGNETCFG, strlen(IGNETCFG))) { - if (ignetcfg != NULL) phree(ignetcfg); + if (ignetcfg != NULL) free(ignetcfg); ignetcfg = NULL; } } diff --git a/citadel/serv_newuser.c b/citadel/serv_newuser.c index 4d0923368..c46f15050 100644 --- a/citadel/serv_newuser.c +++ b/citadel/serv_newuser.c @@ -77,7 +77,7 @@ void CopyNewUserGreetings(void) { cdbfr = cdb_fetch(CDB_MSGLISTS, &CC->room.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -90,7 +90,7 @@ void CopyNewUserGreetings(void) { } /* Now free the memory we used, and go away. */ - if (msglist != NULL) phree(msglist); + if (msglist != NULL) free(msglist); } diff --git a/citadel/serv_pop3.c b/citadel/serv_pop3.c index e04e60b92..b1c8d9f34 100644 --- a/citadel/serv_pop3.c +++ b/citadel/serv_pop3.c @@ -83,7 +83,7 @@ void pop3_cleanup_function(void) { POP3->msgs[i].temp = NULL; } } - if (POP3->msgs != NULL) phree(POP3->msgs); + if (POP3->msgs != NULL) free(POP3->msgs); lprintf(CTDL_DEBUG, "Finished POP3 cleanup hook\n"); } @@ -138,8 +138,8 @@ void pop3_add_message(long msgnum, void *userdata) { lprintf(CTDL_DEBUG, "in pop3_add_message()\n"); ++POP3->num_msgs; - if (POP3->num_msgs < 2) POP3->msgs = mallok(sizeof(struct pop3msg)); - else POP3->msgs = reallok(POP3->msgs, + if (POP3->num_msgs < 2) POP3->msgs = malloc(sizeof(struct pop3msg)); + else POP3->msgs = realloc(POP3->msgs, (POP3->num_msgs * sizeof(struct pop3msg)) ) ; POP3->msgs[POP3->num_msgs-1].msgnum = msgnum; POP3->msgs[POP3->num_msgs-1].deleted = 0; diff --git a/citadel/serv_smtp.c b/citadel/serv_smtp.c index f43a08883..7946661c4 100644 --- a/citadel/serv_smtp.c +++ b/citadel/serv_smtp.c @@ -417,8 +417,8 @@ void smtp_expn(char *argbuf) { /* * Implements the RSET (reset state) command. * Currently this just zeroes out the state buffer. If pointers to data - * allocated with mallok() are ever placed in the state buffer, we have to - * be sure to phree() them first! + * allocated with malloc() are ever placed in the state buffer, we have to + * be sure to free() them first! * * Set do_response to nonzero to output the SMTP RSET response code. */ @@ -566,7 +566,7 @@ void smtp_rcpt(char *argbuf) { && (!SMTP->is_lmtp) ) { if (rbl_check(message_to_spammer)) { cprintf("550 %s\r\n", message_to_spammer); - /* no need to phree(valid), it's not allocated yet */ + /* no need to free(valid), it's not allocated yet */ return; } } @@ -574,7 +574,7 @@ void smtp_rcpt(char *argbuf) { valid = validate_recipients(recp); if (valid->num_error > 0) { cprintf("599 5.1.1 Error: %s\r\n", valid->errormsg); - phree(valid); + free(valid); return; } @@ -582,7 +582,7 @@ void smtp_rcpt(char *argbuf) { if ( (SMTP->message_originated_locally == 0) && (SMTP->is_lmtp == 0) ) { cprintf("551 5.7.1 <%s> - relaying denied\r\n", recp); - phree(valid); + free(valid); return; } } @@ -624,7 +624,7 @@ void smtp_data(void) { cprintf("354 Transmit message now - terminate with '.' by itself\r\n"); datestring(nowstamp, sizeof nowstamp, time(NULL), DATESTRING_RFC822); - body = mallok(4096); + body = malloc(4096); if (body != NULL) snprintf(body, 4096, "Received: from %s (%s [%s])\n" @@ -656,16 +656,16 @@ void smtp_data(void) { * is read with a Citadel client. */ if ( (CC->logged_in) && (config.c_rfc822_strict_from == 0) ) { - if (msg->cm_fields['A'] != NULL) phree(msg->cm_fields['A']); - if (msg->cm_fields['N'] != NULL) phree(msg->cm_fields['N']); - if (msg->cm_fields['H'] != NULL) phree(msg->cm_fields['H']); - if (msg->cm_fields['F'] != NULL) phree(msg->cm_fields['F']); - if (msg->cm_fields['O'] != NULL) phree(msg->cm_fields['O']); - msg->cm_fields['A'] = strdoop(CC->user.fullname); - msg->cm_fields['N'] = strdoop(config.c_nodename); - msg->cm_fields['H'] = strdoop(config.c_humannode); - msg->cm_fields['F'] = strdoop(CC->cs_inet_email); - msg->cm_fields['O'] = strdoop(MAILROOM); + if (msg->cm_fields['A'] != NULL) free(msg->cm_fields['A']); + if (msg->cm_fields['N'] != NULL) free(msg->cm_fields['N']); + if (msg->cm_fields['H'] != NULL) free(msg->cm_fields['H']); + if (msg->cm_fields['F'] != NULL) free(msg->cm_fields['F']); + if (msg->cm_fields['O'] != NULL) free(msg->cm_fields['O']); + msg->cm_fields['A'] = strdup(CC->user.fullname); + msg->cm_fields['N'] = strdup(config.c_nodename); + msg->cm_fields['H'] = strdup(config.c_humannode); + msg->cm_fields['F'] = strdup(CC->cs_inet_email); + msg->cm_fields['O'] = strdup(MAILROOM); } /* Submit the message into the Citadel system. */ @@ -680,7 +680,7 @@ void smtp_data(void) { if (scan_errors > 0) { /* We don't want this message! */ if (msg->cm_fields['0'] == NULL) { - msg->cm_fields['0'] = strdoop( + msg->cm_fields['0'] = strdup( "5.7.1 Message rejected by filter"); } @@ -713,7 +713,7 @@ void smtp_data(void) { } CtdlFreeMessage(msg); - phree(valid); + free(valid); smtp_data_clear(); /* clear out the buffers now */ } @@ -1166,24 +1166,24 @@ void smtp_do_bounce(char *instr) { - bmsg = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage)); + bmsg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); if (bmsg == NULL) return; memset(bmsg, 0, sizeof(struct CtdlMessage)); bmsg->cm_magic = CTDLMESSAGE_MAGIC; bmsg->cm_anon_type = MES_NORMAL; bmsg->cm_format_type = 1; - bmsg->cm_fields['A'] = strdoop("Citadel"); - bmsg->cm_fields['O'] = strdoop(MAILROOM); - bmsg->cm_fields['N'] = strdoop(config.c_nodename); + bmsg->cm_fields['A'] = strdup("Citadel"); + bmsg->cm_fields['O'] = strdup(MAILROOM); + bmsg->cm_fields['N'] = strdup(config.c_nodename); - if (give_up) bmsg->cm_fields['M'] = strdoop( + if (give_up) bmsg->cm_fields['M'] = strdup( "A message you sent could not be delivered to some or all of its recipients\n" "due to prolonged unavailability of its destination(s).\n" "Giving up on the following addresses:\n\n" ); - else bmsg->cm_fields['M'] = strdoop( + else bmsg->cm_fields['M'] = strdup( "A message you sent could not be delivered to some or all of its recipients.\n" "The following addresses were undeliverable:\n\n" ); @@ -1224,7 +1224,7 @@ void smtp_do_bounce(char *instr) { "(%s:%d)\n", __FILE__, __LINE__); } - bmsg->cm_fields['M'] = reallok(bmsg->cm_fields['M'], + bmsg->cm_fields['M'] = realloc(bmsg->cm_fields['M'], strlen(bmsg->cm_fields['M']) + 1024 ); strcat(bmsg->cm_fields['M'], addr); strcat(bmsg->cm_fields['M'], ": "); @@ -1264,7 +1264,7 @@ void smtp_do_bounce(char *instr) { /* Free up the memory we used */ if (valid != NULL) { - phree(valid); + free(valid); } } @@ -1351,7 +1351,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { return; } - instr = strdoop(msg->cm_fields['M']); + instr = strdup(msg->cm_fields['M']); CtdlFreeMessage(msg); /* Strip out the headers amd any other non-instruction line */ @@ -1393,7 +1393,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { */ if (((time(NULL) - last_attempted) < retry) && (run_queue_now == 0)) { lprintf(CTDL_DEBUG, "Retry time not yet reached.\n"); - phree(instr); + free(instr); return; } @@ -1403,7 +1403,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { */ if (text_msgid < 0L) { lprintf(CTDL_ERR, "SMTP: no 'msgid' directive found!\n"); - phree(instr); + free(instr); return; } @@ -1436,11 +1436,11 @@ void smtp_do_procmsg(long msgnum, void *userdata) { smtp_try(key, addr, &status, dsn, sizeof dsn, text_msgid); if (status != 2) { if (results == NULL) { - results = mallok(1024); + results = malloc(1024); memset(results, 0, 1024); } else { - results = reallok(results, + results = realloc(results, strlen(results) + 1024); } snprintf(&results[strlen(results)], 1024, @@ -1451,9 +1451,9 @@ void smtp_do_procmsg(long msgnum, void *userdata) { } if (results != NULL) { - instr = reallok(instr, strlen(instr) + strlen(results) + 2); + instr = realloc(instr, strlen(instr) + strlen(results) + 2); strcat(instr, results); - phree(results); + free(results); } @@ -1481,7 +1481,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { */ if (incomplete_deliveries_remaining > 0) { CtdlDeleteMessages(SMTP_SPOOLOUT_ROOM, msgnum, ""); - msg = mallok(sizeof(struct CtdlMessage)); + msg = malloc(sizeof(struct CtdlMessage)); memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; @@ -1493,7 +1493,7 @@ void smtp_do_procmsg(long msgnum, void *userdata) { "attempted|%ld\n" "retry|%ld\n", SPOOLMIME, instr, (long)time(NULL), (long)retry ); - phree(instr); + free(instr); CtdlSubmitMsg(msg, NULL, SMTP_SPOOLOUT_ROOM); CtdlFreeMessage(msg); } diff --git a/citadel/serv_spam.c b/citadel/serv_spam.c index fd14ad0ac..599869afd 100644 --- a/citadel/serv_spam.c +++ b/citadel/serv_spam.c @@ -83,9 +83,9 @@ int spam_filter(struct CtdlMessage *msg) { if (spam_strings_found) { if (msg->cm_fields['0'] != NULL) { - phree(msg->cm_fields['0']); + free(msg->cm_fields['0']); } - msg->cm_fields['0'] = strdoop("Unsolicited spam rejected"); + msg->cm_fields['0'] = strdup("Unsolicited spam rejected"); return(spam_strings_found); } @@ -164,9 +164,9 @@ int spam_assassin(struct CtdlMessage *msg) { if (is_spam) { if (msg->cm_fields['0'] != NULL) { - phree(msg->cm_fields['0']); + free(msg->cm_fields['0']); } - msg->cm_fields['0'] = strdoop( + msg->cm_fields['0'] = strdup( "5.7.1 Message rejected by SpamAssassin"); } diff --git a/citadel/serv_upgrade.c b/citadel/serv_upgrade.c index 47396e1b8..88d6be709 100644 --- a/citadel/serv_upgrade.c +++ b/citadel/serv_upgrade.c @@ -60,7 +60,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) { */ if (qrbuf != NULL) { ptr = (struct RoomProcList *) - mallok(sizeof (struct RoomProcList)); + malloc(sizeof (struct RoomProcList)); if (ptr == NULL) return; safestrncpy(ptr->name, qrbuf->QRname, sizeof ptr->name); @@ -86,7 +86,7 @@ void cmd_bmbx_backend(struct ctdlroom *qrbuf, void *data) { ptr = rplist; rplist = rplist->next; - phree(ptr); + free(ptr); } } @@ -115,7 +115,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) { */ if (usbuf != NULL) { ptr = (struct UserProcList *) - mallok(sizeof (struct UserProcList)); + malloc(sizeof (struct UserProcList)); if (ptr == NULL) return; safestrncpy(ptr->user, usbuf->fullname, sizeof ptr->user); @@ -136,7 +136,7 @@ void cbtm_backend(struct ctdluser *usbuf, void *data) { ptr = uplist; uplist = uplist->next; - phree(ptr); + free(ptr); } } diff --git a/citadel/serv_vandelay.c b/citadel/serv_vandelay.c index 640fa5ef1..016d7475a 100644 --- a/citadel/serv_vandelay.c +++ b/citadel/serv_vandelay.c @@ -211,7 +211,7 @@ void artv_export_message(long msgnum) { fwrite(smr.ser, smr.len, 1, fp); pclose(fp); - phree(smr.ser); + free(smr.ser); fp = fopen(tempfile, "r"); unlink(tempfile); @@ -504,14 +504,14 @@ void artv_import_message(void) { fclose(fp); lprintf(CTDL_DEBUG, "msglen = %ld\n", msglen); - mbuf = mallok(msglen); + mbuf = malloc(msglen); fp = fopen(tempfile, "rb"); fread(mbuf, msglen, 1, fp); fclose(fp); cdb_store(CDB_MSGMAIN, &msgnum, sizeof(long), mbuf, msglen); - phree(mbuf); + free(mbuf); unlink(tempfile); PutMetaData(&smi); diff --git a/citadel/serv_vcard.c b/citadel/serv_vcard.c index 2689056eb..f7487e403 100644 --- a/citadel/serv_vcard.c +++ b/citadel/serv_vcard.c @@ -113,14 +113,14 @@ void vcard_extract_internet_addresses(struct CtdlMessage *msg, do { s = vcard_get_prop(v, "email;internet", 0, instance++, 0); if (s != NULL) { - addr = strdoop(s); + addr = strdup(s); striplt(addr); if (strlen(addr) > 0) { if (callback != NULL) { callback(addr, citadel_address); } } - phree(addr); + free(addr); found_something = 1; } else { @@ -229,7 +229,7 @@ void vcard_populate_cs_inet_email(struct vCard *v) { s = vcard_get_prop(v, "email;internet", 0, instance++, 0); if (s != NULL) { continue_searching = 1; - addr = strdoop(s); + addr = strdup(s); striplt(addr); if (strlen(addr) > 0) { if (IsDirectory(addr)) { @@ -240,7 +240,7 @@ void vcard_populate_cs_inet_email(struct vCard *v) { ); } } - phree(addr); + free(addr); } else { continue_searching = 0; @@ -320,16 +320,16 @@ int vcard_upload_beforesave(struct CtdlMessage *msg) { * replication always works correctly */ if (msg->cm_fields['E'] != NULL) - phree(msg->cm_fields['E']); + free(msg->cm_fields['E']); if (msg->cm_fields['A'] != NULL) - phree(msg->cm_fields['A']); + free(msg->cm_fields['A']); - msg->cm_fields['A'] = strdoop(usbuf.fullname); + msg->cm_fields['A'] = strdup(usbuf.fullname); snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields['A'], NODENAME); - msg->cm_fields['E'] = strdoop(buf); + msg->cm_fields['E'] = strdup(buf); /* Now allow the save to complete. */ return(0); @@ -477,7 +477,7 @@ void vcard_write_user(struct ctdluser *u, struct vCard *v) { fprintf(fp, "begin:vcard\r\nend:vcard\r\n"); } else { fwrite(ser, strlen(ser), 1, fp); - phree(ser); + free(ser); } fclose(fp); @@ -717,23 +717,23 @@ void vcard_purge(struct ctdluser *usbuf) { struct CtdlMessage *msg; char buf[SIZ]; - msg = (struct CtdlMessage *) mallok(sizeof(struct CtdlMessage)); + msg = (struct CtdlMessage *) malloc(sizeof(struct CtdlMessage)); if (msg == NULL) return; memset(msg, 0, sizeof(struct CtdlMessage)); msg->cm_magic = CTDLMESSAGE_MAGIC; msg->cm_anon_type = MES_NORMAL; msg->cm_format_type = 0; - msg->cm_fields['A'] = strdoop(usbuf->fullname); - msg->cm_fields['O'] = strdoop(ADDRESS_BOOK_ROOM); - msg->cm_fields['N'] = strdoop(NODENAME); - msg->cm_fields['M'] = strdoop("Purge this vCard\n"); + msg->cm_fields['A'] = strdup(usbuf->fullname); + msg->cm_fields['O'] = strdup(ADDRESS_BOOK_ROOM); + msg->cm_fields['N'] = strdup(NODENAME); + msg->cm_fields['M'] = strdup("Purge this vCard\n"); snprintf(buf, sizeof buf, VCARD_EXT_FORMAT, msg->cm_fields['A'], NODENAME); - msg->cm_fields['E'] = strdoop(buf); + msg->cm_fields['E'] = strdup(buf); - msg->cm_fields['S'] = strdoop("CANCEL"); + msg->cm_fields['S'] = strdup("CANCEL"); CtdlSubmitMsg(msg, NULL, ADDRESS_BOOK_ROOM); CtdlFreeMessage(msg); diff --git a/citadel/server.h b/citadel/server.h index cc28f2151..c543de3b7 100644 --- a/citadel/server.h +++ b/citadel/server.h @@ -1,10 +1,5 @@ /* $Id$ */ -/* Uncomment this if you want to track memory leaks. - * This incurs some overhead, so don't use it unless you're debugging the code! - */ -/* #define DEBUG_MEMORY_LEAKS */ - #ifndef SERVER_H #define SERVER_H @@ -439,41 +434,6 @@ struct MetaData { }; - -/* Built-in debuggable stuff for checking for memory leaks */ -#ifdef DEBUG_MEMORY_LEAKS - -#define mallok(howbig) tracked_malloc(howbig, __FILE__, __LINE__) -#define phree(whichptr) tracked_free(whichptr) -#define reallok(whichptr,howbig) tracked_realloc(whichptr,howbig) -#define strdoop(orig) tracked_strdup(orig, __FILE__, __LINE__) - -void *tracked_malloc(size_t, char *, int); -void tracked_free(void *); -void *tracked_realloc(void *, size_t); -void dump_tracked(void); -char *tracked_strdup(const char *, char *, int); - -struct TheHeap { - struct TheHeap *next; - char h_file[32]; - int h_line; - void *h_ptr; -}; - -extern struct TheHeap *heap; - -#else - -#define mallok(howbig) malloc(howbig) -#define phree(whichptr) free(whichptr) -#define reallok(whichptr,howbig) realloc(whichptr,howbig) -#define strdoop(orig) strdup(orig) - - -#endif - - /* * Serialization routines use this struct to return a pointer and a length */ diff --git a/citadel/server_main.c b/citadel/server_main.c index 0b8fa20e9..e2872df5d 100644 --- a/citadel/server_main.c +++ b/citadel/server_main.c @@ -250,7 +250,7 @@ int main(int argc, char **argv) end_critical_section(S_WORKER_LIST); if ((i = pthread_join(wnp->tid, NULL))) lprintf(CTDL_CRIT, "pthread_join: %s\n", strerror(i)); - phree(wnp); + free(wnp); begin_critical_section(S_WORKER_LIST); } end_critical_section(S_WORKER_LIST); diff --git a/citadel/sysdep.c b/citadel/sysdep.c index 95fe7068c..4dc376679 100644 --- a/citadel/sysdep.c +++ b/citadel/sysdep.c @@ -72,10 +72,6 @@ #include "snprintf.h" #endif -#ifdef DEBUG_MEMORY_LEAKS -struct TheHeap *heap = NULL; -#endif - pthread_mutex_t Critters[MAX_SEMAPHORES]; /* Things needing locking */ pthread_key_t MyConKey; /* TSD key for MyContext() */ @@ -175,89 +171,6 @@ void lprintf(enum LogLevel loglevel, const char *format, ...) { -#ifdef DEBUG_MEMORY_LEAKS -void *tracked_malloc(size_t tsize, char *tfile, int tline) { - void *ptr; - struct TheHeap *hptr; - - ptr = malloc(tsize); - if (ptr == NULL) { - lprintf(CTDL_ALERT, "DANGER! mallok(%d) at %s:%d failed!\n", - tsize, tfile, tline); - return(NULL); - } - - hptr = (struct TheHeap *) malloc(sizeof(struct TheHeap)); - strcpy(hptr->h_file, tfile); - hptr->h_line = tline; - hptr->next = heap; - hptr->h_ptr = ptr; - heap = hptr; - return ptr; -} - -char *tracked_strdup(const char *orig, char *tfile, int tline) { - char *s; - - s = tracked_malloc( (strlen(orig)+1), tfile, tline); - if (s == NULL) return NULL; - - strcpy(s, orig); - return s; -} - -void tracked_free(void *ptr) { - struct TheHeap *hptr, *freeme; - - if (heap->h_ptr == ptr) { - hptr = heap->next; - free(heap); - heap = hptr; - } - else { - for (hptr=heap; hptr->next!=NULL; hptr=hptr->next) { - if (hptr->next->h_ptr == ptr) { - freeme = hptr->next; - hptr->next = hptr->next->next; - free(freeme); - } - } - } - - free(ptr); -} - -void *tracked_realloc(void *ptr, size_t size) { - void *newptr; - struct TheHeap *hptr; - - newptr = realloc(ptr, size); - - for (hptr=heap; hptr!=NULL; hptr=hptr->next) { - if (hptr->h_ptr == ptr) hptr->h_ptr = newptr; - } - - return newptr; -} - - -void dump_tracked() { - struct TheHeap *hptr; - - cprintf("%d Here's what's allocated...\n", LISTING_FOLLOWS); - for (hptr=heap; hptr!=NULL; hptr=hptr->next) { - cprintf("%20s %5d\n", - hptr->h_file, hptr->h_line); - } -#ifdef __GNUC__ - malloc_stats(); -#endif - - cprintf("000\n"); -} -#endif - - /* * We used to use master_cleanup() as a signal handler to shut down the server. * however, master_cleanup() and the functions it calls do some things that @@ -461,7 +374,7 @@ INLINE struct CitContext *MyContext(void) { struct CitContext *CreateNewContext(void) { struct CitContext *me, *ptr; - me = (struct CitContext *) mallok(sizeof(struct CitContext)); + me = (struct CitContext *) malloc(sizeof(struct CitContext)); if (me == NULL) { lprintf(CTDL_ALERT, "citserver: can't allocate memory!!\n"); return NULL; @@ -524,7 +437,7 @@ void buffer_output(void) { if (CC->buffering == 0) { CC->buffering = 1; CC->buffer_len = 0; - CC->output_buffer = mallok(SIZ); + CC->output_buffer = malloc(SIZ); } } @@ -535,7 +448,7 @@ void unbuffer_output(void) { if (CC->buffering == 1) { CC->buffering = 0; client_write(CC->output_buffer, CC->buffer_len); - phree(CC->output_buffer); + free(CC->output_buffer); CC->output_buffer = NULL; CC->buffer_len = 0; } @@ -569,7 +482,7 @@ void client_write(char *buf, int nbytes) if (CC->buffering) { old_buffer_len = CC->buffer_len; CC->buffer_len += nbytes; - CC->output_buffer = reallok(CC->output_buffer, CC->buffer_len); + CC->output_buffer = realloc(CC->output_buffer, CC->buffer_len); memcpy(&CC->output_buffer[old_buffer_len], buf, nbytes); return; } @@ -805,7 +718,7 @@ void create_worker(void) { struct worker_node *n; pthread_attr_t attr; - n = mallok(sizeof(struct worker_node)); + n = malloc(sizeof(struct worker_node)); if (n == NULL) { lprintf(CTDL_EMERG, "can't allocate worker_node, exiting\n"); time_to_die = -1; @@ -907,7 +820,7 @@ void dead_session_purge(void) { if ((*node)->tid == self) { tmp = *node; *node = (*node)->next; - phree(tmp); + free(tmp); break; } diff --git a/citadel/user_ops.c b/citadel/user_ops.c index 56559a05e..6f2e12eb4 100644 --- a/citadel/user_ops.c +++ b/citadel/user_ops.c @@ -375,7 +375,7 @@ int CtdlLoginExistingUser(char *trythisname) found_user = getuser(&CC->user, valid->recp_local); } - phree(valid); + free(valid); } } @@ -1577,7 +1577,7 @@ int InitialMailCheck() cdbfr = cdb_fetch(CDB_MSGLISTS, &mailbox.QRnumber, sizeof(long)); if (cdbfr != NULL) { - msglist = mallok(cdbfr->len); + msglist = malloc(cdbfr->len); memcpy(msglist, cdbfr->ptr, cdbfr->len); num_msgs = cdbfr->len / sizeof(long); cdb_free(cdbfr); @@ -1591,7 +1591,7 @@ int InitialMailCheck() } } if (msglist != NULL) - phree(msglist); + free(msglist); return (num_newmsgs); } diff --git a/citadel/vcard.c b/citadel/vcard.c index bf46fd9e9..4c2bcab01 100644 --- a/citadel/vcard.c +++ b/citadel/vcard.c @@ -42,7 +42,7 @@ struct vCard *vcard_new() { struct vCard *v; - v = (struct vCard *) mallok(sizeof(struct vCard)); + v = (struct vCard *) malloc(sizeof(struct vCard)); if (v == NULL) return v; v->magic = CTDL_VCARD_MAGIC; @@ -58,10 +58,10 @@ struct vCard *vcard_new() { */ void vcard_add_prop(struct vCard *v, char *propname, char *propvalue) { ++v->numprops; - v->prop = reallok(v->prop, + v->prop = realloc(v->prop, (v->numprops * sizeof(char *) * 2) ); - v->prop[v->numprops-1].name = strdoop(propname); - v->prop[v->numprops-1].value = strdoop(propvalue); + v->prop[v->numprops-1].name = strdup(propname); + v->prop[v->numprops-1].value = strdup(propvalue); } @@ -77,7 +77,7 @@ struct vCard *vcard_load(char *vtext) { int i; int colonpos, nlpos; - mycopy = strdoop(vtext); + mycopy = strdup(vtext); if (mycopy == NULL) return NULL; /* First, fix this big pile o' vCard to make it more parseable. @@ -104,8 +104,8 @@ struct vCard *vcard_load(char *vtext) { nlpos = pattern2(ptr, "\n"); if ((nlpos > colonpos) && (colonpos > 0)) { - namebuf = mallok(colonpos + 1); - valuebuf = mallok(nlpos - colonpos + 1); + namebuf = malloc(colonpos + 1); + valuebuf = malloc(nlpos - colonpos + 1); strncpy(namebuf, ptr, colonpos); namebuf[colonpos] = 0; strncpy(valuebuf, &ptr[colonpos+1], nlpos-colonpos-1); @@ -118,14 +118,14 @@ struct vCard *vcard_load(char *vtext) { if ( (valid) && (strcasecmp(namebuf, "begin")) ) { ++v->numprops; - v->prop = reallok(v->prop, + v->prop = realloc(v->prop, (v->numprops * sizeof(char *) * 2) ); v->prop[v->numprops-1].name = namebuf; v->prop[v->numprops-1].value = valuebuf; } else { - phree(namebuf); - phree(valuebuf); + free(namebuf); + free(valuebuf); } } @@ -136,7 +136,7 @@ struct vCard *vcard_load(char *vtext) { if (*ptr == '\n') ++ptr; } - phree(mycopy); + free(mycopy); return v; } @@ -185,14 +185,14 @@ void vcard_free(struct vCard *v) { if (v->magic != CTDL_VCARD_MAGIC) return; /* Self-check */ if (v->numprops) for (i=0; i<(v->numprops); ++i) { - phree(v->prop[i].name); - phree(v->prop[i].value); + free(v->prop[i].name); + free(v->prop[i].value); } - if (v->prop != NULL) phree(v->prop); + if (v->prop != NULL) free(v->prop); memset(v, 0, sizeof(struct vCard)); - phree(v); + free(v); } @@ -209,20 +209,20 @@ void vcard_set_prop(struct vCard *v, char *name, char *value, int append) { /* If this key is already present, replace it */ if (!append) if (v->numprops) for (i=0; i<(v->numprops); ++i) { if (!strcasecmp(v->prop[i].name, name)) { - phree(v->prop[i].name); - phree(v->prop[i].value); - v->prop[i].name = strdoop(name); - v->prop[i].value = strdoop(value); + free(v->prop[i].name); + free(v->prop[i].value); + v->prop[i].name = strdup(name); + v->prop[i].value = strdup(value); return; } } /* Otherwise, append it */ ++v->numprops; - v->prop = reallok(v->prop, + v->prop = realloc(v->prop, (v->numprops * sizeof(char *) * 2) ); - v->prop[v->numprops-1].name = strdoop(name); - v->prop[v->numprops-1].value = strdoop(value); + v->prop[v->numprops-1].name = strdup(name); + v->prop[v->numprops-1].value = strdup(value); } @@ -248,7 +248,7 @@ char *vcard_serialize(struct vCard *v) strlen(v->prop[i].value) + 4; } - ser = mallok(len); + ser = malloc(len); if (ser == NULL) return NULL; strcpy(ser, "begin:vcard\r\n");