mem_calloc -> p_new
[apps/madmutt.git] / pager.c
diff --git a/pager.c b/pager.c
index c3800df..31f139a 100644 (file)
--- a/pager.c
+++ b/pager.c
@@ -377,7 +377,7 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
     /* not much point in classifying quotes... */
 
     if (*QuoteList == NULL) {
-      class = (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t));
+      class = p_new(struct q_class_t, 1);
       class->color = ColorQuote[0];
       *QuoteList = class;
     }
@@ -398,10 +398,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
         /* found shorter prefix */
         if (tmp == NULL) {
           /* add a node above q_list */
-          tmp =
-            (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t));
-          tmp->prefix = (char *) mem_calloc (1, length + 1);
-          strncpy (tmp->prefix, qptr, length);
+          tmp = p_new(struct q_class_t, 1);
+          tmp->prefix = p_dupstr(qptr, length);
           tmp->length = length;
 
           /* replace q_list by tmp in the top level list */
@@ -501,11 +499,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
               /* found shorter common prefix */
               if (tmp == NULL) {
                 /* add a node above q_list */
-                tmp = (struct q_class_t *) mem_calloc (1,
-                                                        sizeof (struct
-                                                                q_class_t));
-                tmp->prefix = (char *) mem_calloc (1, length + 1);
-                strncpy (tmp->prefix, qptr, length);
+                tmp = p_new(struct q_class_t, 1);
+                tmp->prefix = p_dupstr(qptr, length);
                 tmp->length = length;
 
                 /* replace q_list by tmp */
@@ -598,10 +593,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
 
         /* still not found so far: add it as a sibling to the current node */
         if (class == NULL) {
-          tmp =
-            (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t));
-          tmp->prefix = (char *) mem_calloc (1, length + 1);
-          strncpy (tmp->prefix, qptr, length);
+          tmp = p_new(struct q_class_t, 1);
+          tmp->prefix = p_dupstr(qptr, length);
           tmp->length = length;
 
           if (ptr->down) {
@@ -632,9 +625,8 @@ static struct q_class_t *classify_quote (struct q_class_t **QuoteList,
 
   if (class == NULL) {
     /* not found so far: add it as a top level class */
-    class = (struct q_class_t *) mem_calloc (1, sizeof (struct q_class_t));
-    class->prefix = (char *) mem_calloc (1, length + 1);
-    strncpy (class->prefix, qptr, length);
+    class = p_new(struct q_class_t, 1);
+    class->prefix = p_dupstr(qptr, length);
     class->length = length;
     new_class_color (class, q_level);