I have a buffer and want to do a test to see if the buffer has sufficient capacity I.e. find number of elements I can add to the buffer.
char *buffer = (char *)malloc(sizeof(char) * 10);
Doing a
int numElements = sizeof(buffer);
does not return 10, any ideas on how I can accomplish this?
To check the buffer window, multiply the bit rate (bits per second) by the buffer window (in seconds) and divide by 1000 to get the size, in bits, of the buffer for the stream.
The maximum size of the buffer. The default value is 65536 (0x10000) bytes.
ptr = (cast-type*) malloc(byte-size) For Example: ptr = (int*) malloc(100 * sizeof(int)); Since the size of int is 4 bytes, this statement will allocate 400 bytes of memory. And, the pointer ptr holds the address of the first byte in the allocated memory.
The buffer allocation model of NvSciBuf is summarized as follows: If two or more hardware engines wants to access a common buffer (e.g., one engine is writing data into the buffer and the other engine is reading from the buffer), then: 1. Applications create an attribute list for each accessor.
You cannot make such a test. It is your own responsibility to remember how much memory you allocated. If the buffer is given to you by someone else, demand that they pass the size information as well, and make it their responsibility to pass the correct value or have the program die.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With