there now exist third-party utilities that do this job better.
$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
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);
/* 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");
}
}
/* 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);
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;
}
}
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);
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);
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);
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);
}
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);
confptr = CtdlReadMessageBody("000",
config.c_maxmsglen, NULL, 0);
CtdlPutSysConfig(confname, confptr);
- phree(confptr);
+ free(confptr);
}
else {
static void dest_tsd(void *arg) {
if (arg != NULL) {
check_handles(arg);
- phree(arg);
+ free(arg);
}
}
if (pthread_getspecific(tsdkey) != NULL)
return;
- tsd = mallok(sizeof(struct cdbtsd));
+ tsd = malloc(sizeof(struct cdbtsd));
tsd->tid = NULL;
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,
abort();
}
- phree(cdb->ptr);
+ free(cdb->ptr);
cdb->len = (size_t) destLen;
cdb->ptr = uncompressed_data;
}
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)),
abort();
}
#ifdef HAVE_ZLIB
- if (compressing) phree(compressed_data);
+ if (compressing) free(compressed_data);
#endif
return ret;
{
txcommit(tid);
#ifdef HAVE_ZLIB
- if (compressing) phree(compressed_data);
+ if (compressing) free(compressed_data);
#endif
return ret;
}
}
if (ret != 0) return NULL;
- tempcdb = (struct cdbdata *) mallok(sizeof(struct cdbdata));
+ tempcdb = (struct cdbdata *) malloc(sizeof(struct cdbdata));
if (tempcdb == NULL)
{
*/
void cdb_free(struct cdbdata *cdb)
{
- phree(cdb->ptr);
- phree(cdb);
+ free(cdb->ptr);
+ free(cdb);
}
void cdb_close_cursor(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
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;
++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) );
}
strcat(mxbuf, mxrecs[n].host);
strcat(mxbuf, "|");
}
- phree(mxrecs);
+ free(mxrecs);
return(num_mxrecs);
}
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);
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) {
strcat(ptr, "|");
}
}
- phree(nttlist);
+ free(nttlist);
nttlist = ptr;
break;
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;
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);
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);
/* 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']);
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;
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);
ftruncate(fileno(fp), ftell(fp));
fflush(fp);
rewind(fp);
- phree(which_fields);
- phree(boiled_headers);
+ free(which_fields);
+ free(boiled_headers);
}
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 ");
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; i<strlen(dumpomatic); ++i) {
}
cprintf("* OK [ALERT] %s\r\n", dumpomatic);
- phree(dumpomatic);
+ free(dumpomatic);
}
cprintf("000\n");
}
}
imap_free_transmitted_message(); /* just in case. */
- IMAP->transmitted_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;
*/
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);
}
}
if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) {
match = 1;
}
- phree(fieldptr);
+ free(fieldptr);
}
pos += 2;
}
if (bmstrstr(fieldptr, itemlist[pos+1], strncasecmp)) {
match = 1;
}
- phree(fieldptr);
+ free(fieldptr);
}
pos += 2;
}
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];
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;
}
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;
}
}
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) {
}
/* 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);
}
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));
/* 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",
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;
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;
* 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;
}
content_type, bytes_decoded, "binary", userdata);
}
- phree(decoded);
+ free(decoded);
}
/*
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 */
}
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);
}
#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
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.
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);
/* 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);
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);
}
/* 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);
++num_processed;
}
}
- phree(msglist); /* Clean up */
+ free(msglist); /* Clean up */
return num_processed;
}
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);
for (i='A'; i<='Z'; ++i) if (msgkeys[i]!=NULL) {
if (!strcasecmp(tfield, msgkeys[i])) {
template->cm_fields[i] =
- strdoop(tvalue);
+ strdup(tvalue);
}
}
}
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;
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 */
/* Always make sure there's something in the msg text field */
if (ret->cm_fields['M'] == NULL)
- ret->cm_fields['M'] = strdoop("<no text>\n");
+ ret->cm_fields['M'] = strdup("<no text>\n");
/* Perform "before read" hooks (aborting if any return nonzero) */
if (PerformMessageHooks(ret, EVT_BEFOREREAD) > 0) {
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);
}
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",
cprintf("%d %ld\n", BINARY_FOLLOWS, (long)smr.len);
client_write(smr.ser, smr.len);
- phree(smr.ser);
+ free(smr.ser);
}
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);
/* Now add the new message */
++num_msgs;
- msglist = reallok(msglist,
+ msglist = realloc(msglist,
(num_msgs * sizeof(long)));
if (msglist == NULL) {
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;
/* 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);
}
/* 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)
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;
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);
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.
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; a<strlen(msg->cm_fields['P']); ++a) {
if (isspace(msg->cm_fields['P'][a])) {
msg->cm_fields['P'][a] = ' ';
}
}
else {
- msg->cm_fields['P'] = strdoop("unknown");
+ msg->cm_fields['P'] = strdup("unknown");
}
}
* 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) */
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, '@');
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;
}
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",
"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);
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);
}
int finished = 0;
if (exist == NULL) {
- m = mallok(4096);
+ m = malloc(4096);
m[0] = 0;
buffer_len = 4096;
message_len = 0;
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;
}
}
/* 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 {
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;
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);
}
}
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) {
cprintf("%d You do not have permission "
"to send Internet mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- phree(valid);
+ free(valid);
return;
}
}
&& (CC->user.axlevel < 4) ) {
cprintf("%d Higher access required for network mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- phree(valid);
+ free(valid);
return;
}
&& (!CC->internal_pgm)) {
cprintf("%d You don't have access to Internet mail.\n",
ERROR + HIGHER_ACCESS_REQUIRED);
- phree(valid);
+ free(valid);
return;
}
if (post == 0) {
cprintf("%d %s\n", CIT_OK,
((valid != NULL) ? valid->display_recp : "") );
- phree(valid);
+ free(valid);
return;
}
CtdlFreeMessage(msg);
}
CC->fake_postname[0] = '\0';
- phree(valid);
+ free(valid);
return;
}
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);
}
/* 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);
}
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);
);
}
- 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;
else {
msg = CtdlFetchMessage(msgnum);
if (msg != NULL) {
- conf = strdoop(msg->cm_fields['M']);
+ conf = strdup(msg->cm_fields['M']);
CtdlFreeMessage(msg);
}
else {
if (recp == NULL) return(0);
if (recp->num_local == 0) {
- phree(recp);
+ free(recp);
return(0);
}
for (i=0; i<recp->num_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);
}
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);
/* 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);
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);
}
}
- if (msglist != NULL) phree(msglist);
+ if (msglist != NULL) free(msglist);
if (CC->room.QRflags & QR_MAILBOX)
rmailflag = 1;
if (me_attend) icalproperty_free(me_attend);
me_attend = icalproperty_new_clone(attendee);
}
- phree(recp);
+ free(recp);
}
}
}
}
/* 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",
CtdlFreeMessage(msg);
}
}
- phree(serialized_reply);
+ free(serialized_reply);
}
* 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);
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",
CIT_ICAL->avoid_sending_invitations = 0;
}
}
- phree(serialized_event);
+ free(serialized_event);
return(0);
}
/* 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");
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",
CtdlFreeMessage(msg);
}
}
- phree(serialized_request);
+ free(serialized_request);
}
);
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;
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",
while ((ChatQueue != NULL) && (now - ChatQueue->chat_time >= 120L)) {
clptr = ChatQueue;
ChatQueue = ChatQueue->next;
- phree(clptr);
+ free(clptr);
}
end_critical_section(S_CHATQUEUE);
}
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);
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");
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);
}
/*
|| (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));
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);
/* 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,
create_room(sl->roomname, 5, "", 0, 1, 1);
CtdlSaveMsgPointerInRoom(sl->roomname, msgnum, 0);
sptr = sl->next;
- phree(sl);
+ free(sl);
sl = sptr;
}
}
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')
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 {
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;
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 */
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");
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);
/* Nothing to do if there aren't any messages */
if (num_msgs == 0) {
- if (msglist != NULL) phree(msglist);
+ if (msglist != NULL) free(msglist);
return;
}
}
}
- if (msglist != NULL) phree(msglist);
+ if (msglist != NULL) free(msglist);
}
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;
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;
} /* !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;
/* 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);
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;
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;
}
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);
/* 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;
/* 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;
}
VisitPurgeList->vp_usernum);
cdb_delete(CDB_VISIT, IndexBuf, IndexLen);
vptr = VisitPurgeList->next;
- phree(VisitPurgeList);
+ free(VisitPurgeList);
VisitPurgeList = vptr;
++purged;
}
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);
while (ul != NULL) {
cdb_delete(CDB_USETABLE, ul->up_key, strlen(ul->up_key));
uptr = ul->next;
- phree(ul);
+ free(ul);
ul = uptr;
}
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;
cprintf("Freeing memory...\n");
while (rr != NULL) {
ptr = rr->next;
- phree(rr);
+ free(rr);
rr = ptr;
}
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");
if (cur == ProtoHookList) {
ProtoHookList = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == LogHookTable) {
LogHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == CleanupHookTable) {
CleanupHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == SessionHookTable) {
SessionHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == UserHookTable) {
UserHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == MessageHookTable) {
MessageHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
struct NetprocFunctionHook *newfcn;
newfcn = (struct NetprocFunctionHook *)
- mallok(sizeof(struct NetprocFunctionHook));
+ malloc(sizeof(struct NetprocFunctionHook));
newfcn->next = NetprocHookTable;
newfcn->h_function_pointer = handler;
NetprocHookTable = newfcn;
if (cur == NetprocHookTable) {
NetprocHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
struct DeleteFunctionHook *newfcn;
newfcn = (struct DeleteFunctionHook *)
- mallok(sizeof(struct DeleteFunctionHook));
+ malloc(sizeof(struct DeleteFunctionHook));
newfcn->next = DeleteHookTable;
newfcn->h_function_pointer = handler;
DeleteHookTable = newfcn;
if (cur == DeleteHookTable) {
DeleteHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
if (cur == XmsgHookTable) {
XmsgHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
}
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 {
else {
strcat(message, "FAILED.");
lprintf(CTDL_CRIT, "%s\n", message);
- phree(newfcn);
+ free(newfcn);
}
}
if (cur == ServiceHookTable) {
ServiceHookTable = p;
}
- phree(cur);
+ free(cur);
cur = p;
}
}
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;
}
}
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;
}
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));
}
*/
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);
}
if (num_msgs != 0)
- phree(msglist);
+ free(msglist);
}
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;
}
irlp = irl;
irl = irl->next;
- phree(irlp);
+ free(irlp);
}
}
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 {
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;
}
}
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; i<n; ++i) {
extract_token(buf, conf, i, '\n');
- sptr = mallok(sizeof(struct spamstrings_t));
- sptr->string = strdoop(buf);
+ sptr = malloc(sizeof(struct spamstrings_t));
+ sptr->string = strdup(buf);
sptr->next = spamstrings;
spamstrings = sptr;
}
* 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 */
}
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;
}
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;
}
}
++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;
}
/* 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;
}
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;
}
/* 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");
}
* 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) {
}
else { /* Not relevant, so *keep* it! */
linelen = strlen(buf);
- holdbuf = reallok(holdbuf,
+ holdbuf = realloc(holdbuf,
(buflen + linelen + 2) );
strcpy(&holdbuf[buflen], buf);
buflen += linelen;
fclose(ncfp);
}
end_critical_section(S_NETCONFIGS);
- phree(holdbuf);
+ free(holdbuf);
}
/*
/* Use the string tokenizer to grab one line at a time */
for (i=0; i<num_tokens(serialized_list, '\n'); ++i) {
extract_token(buf, serialized_list, i, '\n');
- nptr = (struct FilterList *) mallok(sizeof(struct FilterList));
+ nptr = (struct FilterList *) malloc(sizeof(struct FilterList));
extract(nptr->fl_user, buf, 0);
striplt(nptr->fl_user);
extract(nptr->fl_room, buf, 1);
*/
if (strlen(nptr->fl_user) + strlen(nptr->fl_room)
+ strlen(nptr->fl_node) == 0) {
- phree(nptr);
+ free(nptr);
}
else {
nptr->next = newlist;
}
}
- phree(serialized_list);
+ free(serialized_list);
return newlist;
}
void free_filter_list(struct FilterList *fl) {
if (fl == NULL) return;
free_filter_list(fl->next);
- phree(fl);
+ free(fl);
}
/* Use the string tokenizer to grab one line at a time */
for (i=0; i<num_tokens(serialized_map, '\n'); ++i) {
extract_token(buf, serialized_map, i, '\n');
- nmptr = (struct NetMap *) mallok(sizeof(struct NetMap));
+ nmptr = (struct NetMap *) malloc(sizeof(struct NetMap));
extract(nmptr->nodename, buf, 0);
nmptr->lastcontact = extract_long(buf, 1);
extract(nmptr->nexthop, buf, 2);
the_netmap = nmptr;
}
- phree(serialized_map);
+ free(serialized_map);
}
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)],
}
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;
}
}
* 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);
/*
* 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 */
* 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;
/*
* 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
}
}
}
- phree(sermsg.ser);
+ free(sermsg.ser);
CtdlFreeMessage(msg);
}
}
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; i<strlen(buf); ++i) {
if (isspace(buf[i])) buf[i]='_';
buf[i] = tolower(buf[i]);
}
- msg->cm_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;
* 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);
/*
* 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 */
}
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;
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) {
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);
}
/* 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,
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);
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);
}
/* 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, '!');
* 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 */
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)) ) {
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");
}
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];
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]);
}
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);
sermsg.len, 1, fp);
fclose(fp);
}
- phree(sermsg.ser);
+ free(sermsg.ser);
CtdlFreeMessage(msg);
return;
}
"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 */
/* 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;
}
CtdlSubmitMsg(msg, recp, target_room);
}
CtdlFreeMessage(msg);
- phree(recp);
+ free(recp);
}
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);
network_spoolout_room(rplist->name);
ptr = rplist;
rplist = rplist->next;
- phree(ptr);
+ free(ptr);
}
}
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;
}
}
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);
}
/* Now free the memory we used, and go away. */
- if (msglist != NULL) phree(msglist);
+ if (msglist != NULL) free(msglist);
}
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");
}
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;
/*
* 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.
*/
&& (!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;
}
}
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;
}
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;
}
}
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"
* 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. */
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");
}
}
CtdlFreeMessage(msg);
- phree(valid);
+ free(valid);
smtp_data_clear(); /* clear out the buffers now */
}
- 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"
);
"(%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'], ": ");
/* Free up the memory we used */
if (valid != NULL) {
- phree(valid);
+ free(valid);
}
}
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 */
*/
if (((time(NULL) - last_attempted) < retry) && (run_queue_now == 0)) {
lprintf(CTDL_DEBUG, "Retry time not yet reached.\n");
- phree(instr);
+ free(instr);
return;
}
*/
if (text_msgid < 0L) {
lprintf(CTDL_ERR, "SMTP: no 'msgid' directive found!\n");
- phree(instr);
+ free(instr);
return;
}
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,
}
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);
}
*/
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;
"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);
}
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);
}
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");
}
*/
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);
ptr = rplist;
rplist = rplist->next;
- phree(ptr);
+ free(ptr);
}
}
*/
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);
ptr = uplist;
uplist = uplist->next;
- phree(ptr);
+ free(ptr);
}
}
fwrite(smr.ser, smr.len, 1, fp);
pclose(fp);
- phree(smr.ser);
+ free(smr.ser);
fp = fopen(tempfile, "r");
unlink(tempfile);
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);
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 {
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)) {
);
}
}
- phree(addr);
+ free(addr);
}
else {
continue_searching = 0;
* 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);
fprintf(fp, "begin:vcard\r\nend:vcard\r\n");
} else {
fwrite(ser, strlen(ser), 1, fp);
- phree(ser);
+ free(ser);
}
fclose(fp);
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);
/* $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
};
-
-/* 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
*/
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);
#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() */
-#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
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;
if (CC->buffering == 0) {
CC->buffering = 1;
CC->buffer_len = 0;
- CC->output_buffer = mallok(SIZ);
+ CC->output_buffer = malloc(SIZ);
}
}
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;
}
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;
}
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;
if ((*node)->tid == self) {
tmp = *node;
*node = (*node)->next;
- phree(tmp);
+ free(tmp);
break;
}
found_user = getuser(&CC->user,
valid->recp_local);
}
- phree(valid);
+ free(valid);
}
}
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);
}
}
if (msglist != NULL)
- phree(msglist);
+ free(msglist);
return (num_newmsgs);
}
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;
*/
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);
}
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.
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);
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);
}
}
if (*ptr == '\n') ++ptr;
}
- phree(mycopy);
+ free(mycopy);
return 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);
}
/* 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);
}
strlen(v->prop[i].value) + 4;
}
- ser = mallok(len);
+ ser = malloc(len);
if (ser == NULL) return NULL;
strcpy(ser, "begin:vcard\r\n");