home *** CD-ROM | disk | FTP | other *** search
-
- #include "defs.h"
-
- #include <stdlib.h>
- #include <string.h>
-
- #if 0
- /* DEBUG support */
-
- void *grn_malloc (const char *str, const long size)
- {
- static FILE *debug = 0;
-
- debug = fopen ("t:grn_debug", "a");
- fprintf (debug, "m:%s = %ld\n", str, size);
- fclose (debug);
- return malloc (size);
- }
- #endif
-
- /* Normal routines */
-
- ART *AllocART (const char *from, const char *subject)
- {
- int
- len_tot,
- len_from = strlen (from) + 1,
- len_subj = strlen (subject) + 1;
- ART
- *ap;
-
- len_tot = sizeof (ART) + len_from + len_subj;
- ap = (ART *) malloc (len_tot);
- panic0 (ap, "Can't malloc %d bytes for ART", len_tot);
-
- ap->node.ln_Name = ap->header;
-
- ap->from = ((char *) ap) + sizeof (ART);
- memcpy (ap->from, from, len_from);
-
- ap->subject = ap->from + len_from;
- memcpy (ap->subject, subject, len_subj);
-
- return ap;
- }
-
- #ifdef SLOW
- void FreeART (ART *ap)
- {
- if (ap) {
- free ((void *) ap);
- }
- return;
- }
- #endif
-
- NODE *AllocNODE (const char *name, const int len)
- {
- register int
- len_name = len + 1,
- len_tot;
- register NODE
- *node;
-
- len_tot = sizeof (NODE) + len_name;
- node = (NODE *) malloc (len_tot);
- panic0 (node, "Can't alloc %d bytes for NODE", len_tot);
-
- node->ln_Name = ((char *) node) + sizeof (NODE);
- memcpy (node->ln_Name, name, len_name);
-
- return node;
- }
-
- #ifdef SLOW
- void FreeNODE (NODE *node)
- {
- if (node) {
- free ((void *) node);
- }
- return;
- }
- #endif
-
- GLIST *AllocGLIST (const char *in_group, const char *in_header)
- {
- GLIST *gp;
-
- gp = (GLIST *) malloc (sizeof (GLIST));
- panic0 (gp, "Can't malloc GLIST %d bytes\n", sizeof (GLIST));
-
- gp->node.ln_Name = gp->header;
-
- if (in_group)
- strcpy (gp->groupName, in_group);
- else
- strcpy (gp->groupName, "");
- if (in_header)
- strcpy (gp->header, in_header);
- else
- strcpy (gp->header, "");
-
- return gp;
- }
-
- void FreeListNode (LIST *list)
- {
- register NODE *np;
-
- while (np = RemHead (list))
- free (np);
-
- return;
- }
-