ravi688 / bufferlib Goto Github PK
View Code? Open in Web Editor NEWBufferLib is a small library for managing memory buffers
License: MIT License
BufferLib is a small library for managing memory buffers
License: MIT License
function_signature(BUFFER*, BUFcreate, BUFFER* buffer, buf_ucount_t element_size, buf_ucount_t capacity, buf_ucount_t offset)
{
CALLTRACE_BEGIN();
GOOD_ASSERT(((int64_t)element_size) > 0, "element_size cannot be negative or zero");
GOOD_ASSERT(((int64_t)capacity) >= 0, "capacity cannot be negative");
GOOD_ASSERT(((int64_t)offset) >= 0, "offset cannot be negative");
if(buffer == NULL)
{
buffer = malloc(sizeof(BUFFER));
GOOD_ASSERT(buffer != NULL, "Memory Allocation Failure Exception");
buffer->info = 0x00;
buffer->info |= HEAP_ALLOCATED_OBJECT;
buffer->auto_managed_empty_blocks = NULL;
buffer->is_auto_managed = false;
buffer->on_pre_resize = NULL;
buffer->on_post_resize = NULL;
buffer->free = NULL;
}
buffer->bytes = (void*)malloc(element_size * capacity + offset);
GOOD_ASSERT(buffer->bytes != NULL, "Memory Allocation Failure Exception");
buffer->element_size = element_size;
buffer->capacity = capacity;
buffer->element_count = 0;
buffer->offset = offset;
CALLTRACE_RETURN(buffer);
}
if we pass capacity = 0 and offset = 0 then it shouldn't allocate any kind of heap memory given that the BUFFER object is also allocated on the stack.
But here it is not check if the total size of the buffer is zero or not, if it is zero then the buffer->bytes should remain NULL.
buf_push_pseudo(&mesh->vertex_buffers, 1);
vulkan_buffer_t* buffer;
buf_peek(&mesh->vertex_buffers, &buffer);
if(buffer == NULL)
{
puts("NULL");
exit(0);
}
Prints: NULL
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.