Subversion Repositories SvarDOS

Rev

Rev 1340 | Rev 1342 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1340 Rev 1341
Line 83... Line 83...
83
 * functions                                                                 *
83
 * functions                                                                 *
84
 *****************************************************************************/
84
 *****************************************************************************/
85
 
85
 
86
static struct line far *line_calloc(unsigned short siz) {
86
static struct line far *line_calloc(unsigned short siz) {
87
  unsigned int seg;
87
  unsigned int seg;
88
  if (_dos_allocmem((sizeof(struct line) + siz) / 16 + 1, &seg) != 0) return(NULL);
88
  if (_dos_allocmem((sizeof(struct line) + siz + 15) / 16, &seg) != 0) return(NULL);
89
  _fmemset(MK_FP(seg, 0), 0, siz);
89
  _fmemset(MK_FP(seg, 0), 0, siz);
90
  return(MK_FP(seg, 0));
90
  return(MK_FP(seg, 0));
91
}
91
}
92
 
92
 
93
 
93
 
Line 98... Line 98...
98
 
98
 
99
static signed char curline_resize(struct file far *db, unsigned short newsiz) {
99
static signed char curline_resize(struct file far *db, unsigned short newsiz) {
100
  unsigned int maxavail;
100
  unsigned int maxavail;
101
  struct line far *newptr;
101
  struct line far *newptr;
102
 
102
 
103
  /* try resizing the block (faster) */
103
  /* try resizing the block (much faster) */
104
  if (_dos_setblock((sizeof(struct line) + newsiz) / 16 + 1, FP_SEG(db->cursor), &maxavail) == 0) return(0);
104
  if (_dos_setblock((sizeof(struct line) + newsiz + 15) / 16, FP_SEG(db->cursor), &maxavail) == 0) return(0);
105
 
105
 
106
  /* create a new block and copy data over */
106
  /* create a new block and copy data over */
107
  newptr = line_calloc(newsiz);
107
  newptr = line_calloc(newsiz);
108
  if (newptr == NULL) return(-1);
108
  if (newptr == NULL) return(-1);
109
  _fmemmove(newptr, db->cursor, sizeof(struct line) + db->cursor->len);
109
  _fmemmove(newptr, db->cursor, sizeof(struct line) + db->cursor->len);