Subversion Repositories SvarDOS

Rev

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

Rev 1549 Rev 1550
Line 113... Line 113...
113
static void line_free(struct line far *ptr) {
113
static void line_free(struct line far *ptr) {
114
  _dos_freemem(FP_SEG(ptr));
114
  _dos_freemem(FP_SEG(ptr));
115
}
115
}
116
 
116
 
117
 
117
 
118
static int curline_resize(struct file far *db, unsigned short newsiz) {
118
static int curline_resize(struct file *db, unsigned short newsiz) {
119
  unsigned int maxavail;
119
  unsigned int maxavail;
120
  struct line far *newptr;
120
  struct line far *newptr;
121
 
121
 
122
  /* try resizing the block (much faster) */
122
  /* try resizing the block (much faster) */
123
  if (_dos_setblock((sizeof(struct line) + newsiz + 15) / 16, FP_SEG(db->cursor), &maxavail) == 0) return(0);
123
  if (_dos_setblock((sizeof(struct line) + newsiz + 15) / 16, FP_SEG(db->cursor), &maxavail) == 0) return(0);
Line 202... Line 202...
202
 
202
 
203
}
203
}
204
 
204
 
205
 
205
 
206
/* append a nul-terminated string to line at cursor position */
206
/* append a nul-terminated string to line at cursor position */
207
static int line_append(struct file *f, const char far *buf, unsigned short len) {
207
static int line_append(struct file *f, const char *buf, unsigned short len) {
208
  if (sizeof(struct line) + f->cursor->len + len < len) goto ERR; /* overflow check */
208
  if (sizeof(struct line) + f->cursor->len + len < len) goto ERR; /* overflow check */
209
  if (curline_resize(f, f->cursor->len + len) != 0) goto ERR;
209
  if (curline_resize(f, f->cursor->len + len) != 0) goto ERR;
210
 
210
 
211
  _fmemmove(f->cursor->payload + f->cursor->len, buf, len);
211
  _fmemmove(f->cursor->payload + f->cursor->len, buf, len);
212
  f->cursor->len += len;
212
  f->cursor->len += len;