~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_dynrec.c

  • Committer: Brian Aker
  • Date: 2008-12-06 23:57:32 UTC
  • mfrom: (656.1.10 devel)
  • Revision ID: brian@tangent.org-20081206235732-jx228bczpvmxu8ww
Merge from Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
/*
17
17
  Functions to handle space-packed-records and blobs
18
 
 
 
18
 
19
19
  A row may be stored in one or more linked blocks.
20
20
  The block size is between MI_MIN_BLOCK_LENGTH and MI_MAX_BLOCK_LENGTH.
21
21
  Each block is aligned on MI_DYN_ALIGN_SIZE.
47
47
static int _mi_cmp_buffer(File file, const unsigned char *buff, my_off_t filepos,
48
48
                          uint32_t length);
49
49
 
50
 
/* Play it safe; We have a small stack when using threads */
51
 
#undef my_alloca
52
 
#undef my_afree
53
 
#define my_alloca(A) malloc((A))
54
 
#define my_afree(A) free((A))
55
 
 
56
50
        /* Interface function from MI_INFO */
57
51
 
58
52
#ifdef HAVE_MMAP
134
128
    Buffer              Input buffer
135
129
    Count               Count of bytes for read
136
130
    offset              Start position
137
 
    MyFlags             
 
131
    MyFlags
138
132
 
139
133
  RETURN
140
134
    0  ok
187
181
    Buffer              Output buffer
188
182
    Count               Count of bytes for write
189
183
    offset              Start position
190
 
    MyFlags             
 
184
    MyFlags
191
185
 
192
186
  RETURN
193
187
    0  ok
209
203
 
210
204
  if (info->s->mmaped_length >= offset + Count)
211
205
  {
212
 
    memcpy(info->s->file_map + offset, Buffer, Count); 
 
206
    memcpy(info->s->file_map + offset, Buffer, Count);
213
207
    if (info->s->concurrent_insert)
214
208
      pthread_rwlock_unlock(&info->s->mmap_lock);
215
209
    return 0;
263
257
    return -1;
264
258
  }
265
259
#endif
266
 
  if (!(rec_buff=(unsigned char*) my_alloca(reclength)))
 
260
  if (!(rec_buff=(unsigned char*) malloc(reclength)))
267
261
  {
268
262
    my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */
269
263
    return(-1);
273
267
  assert(reclength2 <= reclength);
274
268
  error=write_dynamic_record(info,rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER),
275
269
                             reclength2);
276
 
  my_afree(rec_buff);
 
270
  free(rec_buff);
277
271
  return(error);
278
272
}
279
273
 
295
289
    return -1;
296
290
  }
297
291
#endif
298
 
  if (!(rec_buff=(unsigned char*) my_alloca(reclength)))
 
292
  if (!(rec_buff=(unsigned char*) malloc(reclength)))
299
293
  {
300
294
    my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */
301
295
    return(-1);
305
299
  error=update_dynamic_record(info,pos,
306
300
                              rec_buff+ALIGN_SIZE(MI_MAX_DYN_BLOCK_HEADER),
307
301
                              reclength);
308
 
  my_afree(rec_buff);
 
302
  free(rec_buff);
309
303
  return(error);
310
304
}
311
305
 
1508
1502
  unsigned char *rec_buff,*old_record;
1509
1503
  int error;
1510
1504
 
1511
 
  if (!(old_record=my_alloca(info->s->base.reclength)))
 
1505
  if (!(old_record=malloc(info->s->base.reclength)))
1512
1506
    return(1);
1513
1507
 
1514
1508
  /* Don't let the compare destroy blobs that may be in use */
1525
1519
      free(rec_buff_ptr);
1526
1520
    info->rec_buff=rec_buff;
1527
1521
  }
1528
 
  my_afree(old_record);
 
1522
  free(old_record);
1529
1523
  return(error);
1530
1524
}
1531
1525
 
1554
1548
  {                                             /* If check isn't disabled  */
1555
1549
    if (info->s->base.blobs)
1556
1550
    {
1557
 
      if (!(buffer=(unsigned char*) my_alloca(info->s->base.pack_reclength+
 
1551
      if (!(buffer=(unsigned char*) malloc(info->s->base.pack_reclength+
1558
1552
                                     _my_calc_total_blob_length(info,record))))
1559
1553
        return(-1);
1560
1554
    }
1602
1596
  my_errno=0;
1603
1597
err:
1604
1598
  if (buffer != info->rec_buff)
1605
 
    my_afree((unsigned char*) buffer);
 
1599
    free((unsigned char*) buffer);
1606
1600
  return(my_errno);
1607
1601
}
1608
1602