Skip to content

BufDeinit

Description

Release the backing storage of a Buf through its inline allocator.

Success

Returns to the caller. *b is zeroed.

Failure

Macro cannot fail. Safe on a zeroed Buf.

Usage example (Cross-references)

Usage examples (Cross-references)
        Buf data = BufInit(alloc);
        if (FileReadAndClose(path, &data) < 0) {
            BufDeinit(&data);
            LOG_ERROR("MachoOpen: failed to read {}", path);
            return false;
        if (!self)
            return;
        BufDeinit(&self->data);
        VecDeinit(&self->segments);
        VecDeinit(&self->sections);
        Buf data = BufInit(alloc);
        if (FileReadAndClose(path, &data) < 0) {
            BufDeinit(&data);
            LOG_ERROR("ElfOpen: failed to read {}", path);
            return false;
        if (!self)
            return;
        BufDeinit(&self->data);
        VecDeinit(&self->sections);
        VecDeinit(&self->symbols);
        Buf data = BufInit(alloc);
        if (FileReadAndClose(path, &data) < 0) {
            BufDeinit(&data);
            LOG_ERROR("PdbOpen: failed to read {}", path);
            return false;
            return;
        Allocator *alloc = BufAllocator(&self->data);
        BufDeinit(&self->data);
        if (alloc) {
            if (self->name_pool)
        Buf data = BufInit(alloc);
        if (FileReadAndClose(path, &data) < 0) {
            BufDeinit(&data);
            LOG_ERROR("PeOpen: failed to read {}", path);
            return false;
        if (!self)
            return;
        BufDeinit(&self->data);
        VecDeinit(&self->sections);
        MemSet(self, 0, sizeof(*self));
        BufClear(&b);
        ok = ok && BufLength(&b) == 0;
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        };
        bool ok = BufLength(&b) == sizeof(expect) && MemCompare(BufData(&b), expect, sizeof(expect)) == 0;
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        const u8 expect_uleb[] = {0x00, 0x7F, 0x80, 0x01, 0x80, 0x80, 0x01};
        if (BufLength(&b) != sizeof(expect_uleb) || MemCompare(BufData(&b), expect_uleb, sizeof(expect_uleb)) != 0) {
            BufDeinit(&b);
            DefaultAllocatorDeinit(&alloc);
            return false;
        bool ok = BufLength(&b) == sizeof(expect_sleb) && MemCompare(BufData(&b), expect_sleb, sizeof(expect_sleb)) == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        const u8 expect[] = {'h', 'i', 0};
        bool     ok       = BufLength(&b) == sizeof(expect) && MemCompare(BufData(&b), expect, sizeof(expect)) == 0;
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok         = ok && IterRemainingLength(&it) == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok         = ok && IterRemainingLength(&it) == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok         = ok && IterRemainingLength(&it) == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        const u8 expect[] = {0x99, 0xFE, 0xCA, 0xDE, 0xAD, 0xBE, 0xEF};
        ok                = ok && BufLength(&b) == sizeof(expect) && MemCompare(BufData(&b), expect, sizeof(expect)) == 0;
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        const u8 expect[] = {0x34, 0x12};
        ok                = ok && BufLength(&b) == sizeof(expect) && MemCompare(BufData(&b), expect, sizeof(expect)) == 0;
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && BufLength(&b) == BufLength(&snapshot);
        ok = ok && MemCompare(BufData(&b), BufData(&snapshot), BufLength(&b)) == 0;
        BufDeinit(&snapshot);
    
        BufDeinit(&b);
        BufDeinit(&snapshot);
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok         = ok && IterRemainingLength(&it) == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
        ok = ok && it.pos == entry && v32 == 0;
    
        BufDeinit(&b);
        DefaultAllocatorDeinit(&alloc);
        return ok;
Last updated on