arrays - C++ fill an empty buffer with a single value -


i apologize in advance if using incorrect terminology, i'm new c++ language. have class constructor creates empty buffer using malloc

lpd6803pwm::lpd6803pwm(uint16_t leds, uint8_t dout, uint8_t cout) {     numleds = leds;     pixels = (uint16_t *) malloc(numleds);     datapin = dout;     clockpin = cout; } 

my understanding creates empty buffer length of whatever pass numleds dynamically created array correct? i'm using malloc because code goes on arduino has limited memory , want avoid overflows , have read, best way declare arrays don't know size array , want avoid overflow errors.

my question is, once array has been created there faster way traditional loop fill array single value. want , microseconds make difference in application. know c++ standard library array classes have fill method, array declared in way?

my question is, once array has been created there faster way traditional loop fill array single value.

the c standard library provides memset() , related functions filling buffer. there's calloc(), allocates buffer malloc(), fills buffer 0 @ same time.

very want , microseconds make difference in application.

in case might consider ways avoid repeatedly allocating array, take more time filling existing array. well, easiest way make code go faster run on faster hardware. arduino great platform, raspberry pi 0 costs less ($5, if can find them), has lot more memory, , has clock speed that's 64x faster typical arduino (1ghz vs. 16mhz). computing tradeoff between good, cheap, , fast, in case three.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -