What is the standard procedure to allocate memory on the stack. I am currently creating a temporary array
const uint8_t _buf[buf_size];
const uint8_t* buf = _buf;
I never use _buf again. I feel dirty. Is there a better way?
Edit:
The reason I need the pointer is because I am passing it to a function which increments the pointer. I dont believe this will work well with passing an array. Here are more details:
const uint8_t _buf[buf_size];
const uint8_t* buf = _buf;
buf_size = fread((void *)buf, 1, buf_size, file);
// f increments the pointer in buf
f(&buf, &buf_size);
_bufas the source for the initialization ofbuf, it's equivalent toconst uint8_t* buf = &_buf[0];. So you don't needbufonly the array, if will behave as you expect when you need a pointer._buf? The array allocates memory on the stack as you want. What's the reason to use another pointer?