[BACK]Return to extend.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / mg

Diff for /src/usr.bin/mg/extend.c between version 1.44 and 1.45

version 1.44, 2005/12/20 06:17:36 version 1.45, 2006/03/30 18:32:07
Line 5 
Line 5 
 /*  /*
  *      Extended (M-X) commands, rebinding, and startup file processing.   *      Extended (M-X) commands, rebinding, and startup file processing.
  */   */
   #include <sys/types.h>
   #include <ctype.h>
   
 #include "chrdef.h"  #include "chrdef.h"
 #include "def.h"  #include "def.h"
 #include "kbd.h"  #include "kbd.h"
 #include "funmap.h"  #include "funmap.h"
   
 #include <ctype.h>  
   
 #ifndef NO_MACRO  #ifndef NO_MACRO
 #include "macro.h"  #include "macro.h"
 #endif /* !NO_MACRO */  #endif /* !NO_MACRO */
Line 115 
Line 116 
                         n2 = HUGE;                          n2 = HUGE;
                 if (n1 <= MAPELEDEF && n1 <= n2) {                  if (n1 <= MAPELEDEF && n1 <= n2) {
                         ele--;                          ele--;
                         if ((pfp = (PF *)malloc((c - ele->k_base + 1) *                          if ((pfp = calloc(c - ele->k_base + 1,
                             sizeof(PF))) == NULL) {                              sizeof(PF))) == NULL) {
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
Line 129 
Line 130 
                         ele->k_num = c;                          ele->k_num = c;
                         ele->k_funcp = pfp;                          ele->k_funcp = pfp;
                 } else if (n2 <= MAPELEDEF) {                  } else if (n2 <= MAPELEDEF) {
                         if ((pfp = (PF *)malloc((ele->k_num - c + 1) *                          if ((pfp = calloc(ele->k_num - c + 1,
                             sizeof(PF))) == NULL) {                              sizeof(PF))) == NULL) {
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
Line 170 
Line 171 
                         if (pref_map != NULL)                          if (pref_map != NULL)
                                 ele->k_prefmap = pref_map;                                  ele->k_prefmap = pref_map;
                         else {                          else {
                                 if ((mp = (KEYMAP *)malloc(sizeof(KEYMAP) +                                  if ((mp = malloc(sizeof(KEYMAP) +
                                     (MAPINIT - 1) * sizeof(struct map_element))) == NULL) {                                      (MAPINIT - 1) * sizeof(struct map_element))) == NULL) {
                                         ewprintf("Out of memory");                                          ewprintf("Out of memory");
                                         ele->k_funcp[c - ele->k_base] =                                          ele->k_funcp[c - ele->k_base] =
Line 224 
Line 225 
                         if (curmap->map_num >= curmap->map_max &&                          if (curmap->map_num >= curmap->map_max &&
                             (curmap = reallocmap(curmap)) == NULL)                              (curmap = reallocmap(curmap)) == NULL)
                                 return (FALSE);                                  return (FALSE);
                         if ((pfp = malloc((ele->k_num - c + !n2) *                          if ((pfp = calloc(ele->k_num - c + !n2,
                             sizeof(PF))) == NULL) {                              sizeof(PF))) == NULL) {
                                 ewprintf("Out of memory");                                  ewprintf("Out of memory");
                                 return (FALSE);                                  return (FALSE);
Line 274 
Line 275 
         KEYMAP  *mp;          KEYMAP  *mp;
         int      i;          int      i;
   
         if ((mp = (KEYMAP *)malloc((unsigned)(sizeof(KEYMAP) +          if (curmap->map_max > SHRT_MAX - MAPGROW) {
             (curmap->map_max + (MAPGROW - 1)) *                  ewprintf("keymap too large");
             sizeof(struct map_element)))) == NULL) {                  return (NULL);
           }
           if ((mp = malloc(sizeof(KEYMAP) + (curmap->map_max + (MAPGROW - 1)) *
               sizeof(struct map_element))) == NULL) {
                 ewprintf("Out of memory");                  ewprintf("Out of memory");
                 return (NULL);                  return (NULL);
         }          }

Legend:
Removed from v.1.44  
changed lines
  Added in v.1.45