~ubuntu-branches/ubuntu/vivid/mariadb-5.5/vivid-proposed

« back to all changes in this revision

Viewing changes to storage/tokudb/ft-index/util/mempool.cc

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2014-11-14 21:04:24 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20141114210424-xlyna0ozl11647o5
Tags: 5.5.40-0ubuntu0.14.10.1
* SECURITY UPDATE: Update to 5.5.40 to fix security issues (LP: #1391676)
  - CVE-2014-6507
  - CVE-2014-6491
  - CVE-2014-6500
  - CVE-2014-6469
  - CVE-2014-6555
  - CVE-2014-6559
  - CVE-2014-6494
  - CVE-2014-6496
  - CVE-2014-6464
* Add bsdutils as mariadb-server dependency like upstream does in 5.5.40.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
COPYRIGHT NOTICE:
31
31
 
32
 
  TokuDB, Tokutek Fractal Tree Indexing Library.
 
32
  TokuFT, Tokutek Fractal Tree Indexing Library.
33
33
  Copyright (C) 2007-2013 Tokutek, Inc.
34
34
 
35
35
DISCLAIMER:
207
207
    return mp->free_offset;
208
208
}
209
209
 
210
 
void *toku_mempool_malloc(struct mempool *mp, size_t size, int alignment) {
 
210
void *toku_mempool_malloc(struct mempool *mp, size_t size) {
211
211
    paranoid_invariant(size < (1U<<31));
212
212
    paranoid_invariant(mp->size < (1U<<31));
213
213
    paranoid_invariant(mp->free_offset < (1U<<31));
214
214
    paranoid_invariant(mp->free_offset <= mp->size);
215
215
    void *vp;
216
 
    size_t offset = (mp->free_offset + (alignment-1)) & ~(alignment-1);
217
 
    //printf("mempool_malloc size=%ld base=%p free_offset=%ld mp->size=%ld offset=%ld\n", size, mp->base, mp->free_offset, mp->size, offset);
218
 
    if (offset + size > mp->size) {
219
 
        vp = 0;
 
216
    if (mp->free_offset + size > mp->size) {
 
217
        vp = nullptr;
220
218
    } else {
221
 
        vp = (char *)mp->base + offset;
222
 
        mp->free_offset = offset + size;
 
219
        vp = reinterpret_cast<char *>(mp->base) + mp->free_offset;
 
220
        mp->free_offset += size;
223
221
    }
224
222
    paranoid_invariant(mp->free_offset <= mp->size);
225
 
    paranoid_invariant(((long)vp & (alignment-1)) == 0);
226
223
    paranoid_invariant(vp == 0 || toku_mempool_inrange(mp, vp, size));
227
 
    //printf("mempool returning %p\n", vp);
228
224
    return vp;
229
225
}
230
226
 
232
228
void toku_mempool_mfree(struct mempool *mp, void *vp, size_t size) {
233
229
    if (vp) { paranoid_invariant(toku_mempool_inrange(mp, vp, size)); }
234
230
    mp->frag_size += size;
235
 
    paranoid_invariant(mp->frag_size <= mp->size);
 
231
    invariant(mp->frag_size <= mp->free_offset);
 
232
    invariant(mp->frag_size <= mp->size);
236
233
}
237
234
 
238
235