Magellan Linux

Diff of /trunk/mkinitrd-magellan/busybox/editors/ed.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 983 by niro, Fri Apr 24 18:33:46 2009 UTC revision 984 by niro, Sun May 30 11:32:42 2010 UTC
# Line 454  static void subCommand(const char *cmd, Line 454  static void subCommand(const char *cmd,
454   * structure and use that.  Link it in in place of   * structure and use that.  Link it in in place of
455   * the old line structure.   * the old line structure.
456   */   */
457   nlp = malloc(sizeof(LINE) + lp->len + deltaLen);   nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen);
  if (nlp == NULL) {  
  bb_error_msg("cannot get memory for line");  
  return;  
  }  
458    
459   nlp->len = lp->len + deltaLen;   nlp->len = lp->len + deltaLen;
460    
# Line 686  static int readLines(const char *file, i Line 682  static int readLines(const char *file, i
682   cc = 0;   cc = 0;
683    
684   printf("\"%s\", ", file);   printf("\"%s\", ", file);
685   fflush(stdout);   fflush_all();
686    
687   do {   do {
688   cp = memchr(bufPtr, '\n', bufUsed);   cp = memchr(bufPtr, '\n', bufUsed);
# Line 712  static int readLines(const char *file, i Line 708  static int readLines(const char *file, i
708    
709   if (bufUsed >= bufSize) {   if (bufUsed >= bufSize) {
710   len = (bufSize * 3) / 2;   len = (bufSize * 3) / 2;
711   cp = realloc(bufBase, len);   cp = xrealloc(bufBase, len);
  if (cp == NULL) {  
  bb_error_msg("no memory for buffer");  
  close(fd);  
  return FALSE;  
  }  
712   bufBase = cp;   bufBase = cp;
713   bufPtr = bufBase + bufUsed;   bufPtr = bufBase + bufUsed;
714   bufSize = len;   bufSize = len;
# Line 775  static int writeLines(const char *file, Line 766  static int writeLines(const char *file,
766   }   }
767    
768   printf("\"%s\", ", file);   printf("\"%s\", ", file);
769   fflush(stdout);   fflush_all();
770    
771   lp = findLine(num1);   lp = findLine(num1);
772   if (lp == NULL) {   if (lp == NULL) {
# Line 872  static int insertLine(int num, const cha Line 863  static int insertLine(int num, const cha
863   return FALSE;   return FALSE;
864   }   }
865    
866   newLp = malloc(sizeof(LINE) + len - 1);   newLp = xmalloc(sizeof(LINE) + len - 1);
  if (newLp == NULL) {  
  bb_error_msg("failed to allocate memory for line");  
  return FALSE;  
  }  
867    
868   memcpy(newLp->data, data, len);   memcpy(newLp->data, data, len);
869   newLp->len = len;   newLp->len = len;
# Line 951  static void deleteLines(int num1, int nu Line 938  static void deleteLines(int num1, int nu
938   * Returns the line number which matches, or 0 if there was no match   * Returns the line number which matches, or 0 if there was no match
939   * with an error printed.   * with an error printed.
940   */   */
941  static int searchLines(const char *str, int num1, int num2)  static NOINLINE int searchLines(const char *str, int num1, int num2)
942  {  {
943   const LINE *lp;   const LINE *lp;
944   int len;   int len;
# Line 983  static int searchLines(const char *str, Line 970  static int searchLines(const char *str,
970   lp = lp->next;   lp = lp->next;
971   }   }
972    
973   bb_error_msg("cannot find string \"%s\"", str);   bb_error_msg("can't find string \"%s\"", str);
974   return 0;   return 0;
975  }  }
976    

Legend:
Removed from v.983  
changed lines
  Added in v.984