summaryrefslogtreecommitdiffstats
path: root/vespamalloc/src/tests/allocfree/realloc.cpp
blob: efaf89f7e1b763f2bcb1c9f69ac77b302ec8d065 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/testkit/testapp.h>

TEST_SETUP(Test);

int Test::Main() {
    char * v = static_cast<char *>(malloc(0x400001));
    char * nv = static_cast<char *>(realloc(v, 0x500001));
    ASSERT_TRUE(v == nv);
    v = static_cast<char *>(realloc(nv, 0x600001));
    ASSERT_TRUE(v != nv);
    free(v);

    char *t = static_cast<char *>(malloc(70));
    free (t+7);
    t = static_cast<char *>(malloc(0x400001));
    free (t+7);
    return 0;
}