Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Changeset 803

Show
Ignore:
Timestamp:
12/13/10 02:51:45 (14 years ago)
Author:
braddr
Message:

Allocator interface uses size_t, not uint.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/runnable/newdel.d

    r575 r803  
    11// PERMUTE_ARGS: 
    22 
    33import std.c.stdio; 
    44import std.c.stdlib; 
    55 
    66/*********************************************/ 
    77 
    88class Foo 
    99{ 
    1010    static uint flags; 
    1111 
    12     new(uint sz, int x) 
     12    new(size_t sz, int x) 
    1313    {   void* p; 
    1414 
    1515    printf("Foo.new(sz = %d, x = %d)\n", sz, x); 
    1616    assert(sz == Foo.classinfo.init.length); 
    1717    assert(x == 5); 
    1818 
    1919    p = std.c.stdlib.malloc(sz); 
    2020    flags |= 4; 
    2121    return p; 
    2222    } 
    2323 
    2424    this() 
    2525    { 
    2626    printf("this() %p\n", this); 
    2727    a = 36; 
    2828    } 
    2929 
    3030    ~this() 
    3131    { 
    3232    printf("~this() %p\n", this); 
     
    5050{ 
    5151    Foo f; 
    5252 
    5353    f = new(5) Foo; 
    5454    assert(f.a == 36); 
    5555    assert(f.b == 4); 
    5656    assert(f.d == 56); 
    5757    assert(Foo.flags == 4); 
    5858 
    5959    delete f; 
    6060    assert(Foo.flags == 7); 
    6161} 
    6262 
    6363 
    6464/*********************************************/ 
    6565 
    6666struct Foo2 
    6767{ 
    6868    static uint flags; 
    6969 
    70     new(uint sz, int x) 
     70    new(size_t sz, int x) 
    7171    {   void* p; 
    7272 
    7373    printf("Foo2.new(sz = %d, x = %d)\n", sz, x); 
    7474    assert(sz == Foo2.sizeof); 
    7575    assert(x == 5); 
    7676 
    7777    p = std.c.stdlib.malloc(sz); 
    7878    flags |= 4; 
    7979    return p; 
    8080    } 
    8181 
    8282    delete(void *p) 
    8383    { 
    8484    printf("p = %p\n", p); 
    8585    flags |= 2; 
    8686    std.c.stdlib.free(p); 
    8787    } 
    8888} 
    8989 
    9090void test2()