Giter Site home page Giter Site logo

ravi688 / bufferlib Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 180 KB

BufferLib is a small library for managing memory buffers

License: MIT License

C 86.32% Makefile 9.45% C++ 4.23%
memory memory-buffers buffers fifo stack queue traversal insertion deletion

bufferlib's People

Contributors

ravi688 avatar

Stargazers

 avatar  avatar

Watchers

 avatar

bufferlib's Issues

Fix BUFcreate

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 not working correctly

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.