opendps icon indicating copy to clipboard operation
opendps copied to clipboard

Dynamic memory usage?

Open Xenoamor opened this issue 5 years ago • 5 comments

Any ideas how the following code compiles? https://github.com/kanflo/opendps/blob/c1a8ab69d97ee3a329a2283ec88c49150537978c/opendps/uframe.h#L44 https://github.com/kanflo/opendps/blob/c1a8ab69d97ee3a329a2283ec88c49150537978c/opendps/uframe.h#L47-L52 https://github.com/kanflo/opendps/blob/c1a8ab69d97ee3a329a2283ec88c49150537978c/opendps/protocol_handler.c#L348-L351

I've never seen uint8_t buffer[variable]; compile before

Xenoamor avatar Oct 01 '19 19:10 Xenoamor

I've scrubbed this in #176 as I really didn't like the look of it

Xenoamor avatar Oct 01 '19 22:10 Xenoamor

I guess this is one of the places where a static allocation would be suitable.

kanflo avatar Oct 02 '19 20:10 kanflo

As far as I'm aware this isn't valid C at all. It still baffles me how it compiles

Xenoamor avatar Oct 02 '19 22:10 Xenoamor

I think it is Well, sort of, because gcc is the only compiller I've used that has it implemented;)

m-kozlowski avatar Oct 02 '19 23:10 m-kozlowski

I had no idea this was a thing. Seems pretty dangerous to me if you're trying to avoid the heap

Xenoamor avatar Oct 02 '19 23:10 Xenoamor