umalloc-ufree and malloc-free Vs read and fread - General Discussion and Assistance - CHDK Forum supplierdeeply

umalloc-ufree and malloc-free Vs read and fread

  • 3 Replies
  • 2416 Views
*

Offline Lebeau

  • ***
  • 187
umalloc-ufree and malloc-free Vs read and fread
« on: 03 / February / 2011, 11:59:26 »
Advertisements
Bonjour,

After reading developer section, I understand difference between umalloc and malloc, and their reciprocal ufree and free.

But why uncached mem shall be used when using "read-like" function and faster cache memory can be used with "fread-like" functions ?

I visit trunk1054 c files for occurence.

dancingbits - line 57 : malloc when use with fread
dng - line 398 : malloc when use in fread
dumpchk - line 105 & 162 : malloc when use with fread
dumputil - line 98 : malloc when use with fread
extract_event_procedures - line 72 : malloc when use with fread
finsig - line 100 : malloc when use with fread (didn't find a free)
gui_sokoban - line 149 : malloc when use with fread
gui_sokoban - line 277 : malloc when use with fread
pakwif - line 253 : malloc when use with fseek (line 326, ...)
ptp - line 300 : malloc when use with fwrite
raw - line 454 : malloc when use with fread
raw_merge - line 69 & 70 : malloc used with fread
raw_merge - line 203 & 206 : malloc used with fread
rawconvert - line 307 & 325 : malloc use with fread and fwrite
run-ubasic - line 73 : malloc use with fread
script - line 367 : malloc use with fread
yuvconvert - line 161, 163, 165 & 208 : malloc when use with fread or fwrite

Shall I conclude that " f " file operations are so different than block file operations in Powershot ?

And, I found these incongruities that I submit to whom is concerned.

raw - line 242 : malloc when use with  write  :blink:
raw - line 269 : free when use with  write  :blink:

rbf_font - line 108 & 165 : malloc use with  read :blink:


Re: umalloc-ufree and malloc-free Vs read and fread
« Reply #1 on: 05 / February / 2011, 21:09:43 »
I have wondered about exactly the same things.

I think reyalp posted something a long time ago about this.


*

Online reyalp

  • ******
  • 12589
Re: umalloc-ufree and malloc-free Vs read and fread
« Reply #2 on: 08 / February / 2011, 13:23:34 »
Bonjour,

After reading developer section, I understand difference between umalloc and malloc, and their reciprocal ufree and free.

But why uncached mem shall be used when using "read-like" function and faster cache memory can be used with "fread-like" functions ?
Because one some cameras read() and write() do not operate reliably using cached memory, presumably because they do DMA without any additional bufffering. The FUT functions (fread frwrite etc.) allocate their own buffer of uncached memory to feed to read and write.

There are still some places where read and write are used with cached memory (typically stack variables). This is a bug.

See http://chdk.wikia.com/wiki/CHDK_Coding_Guidelines#Memory_allocation
Don't forget what the H stands for.

*

Offline Lebeau

  • ***
  • 187
Re: umalloc-ufree and malloc-free Vs read and fread
« Reply #3 on: 08 / February / 2011, 15:43:52 »
thanks reyalp, I already read these well-explained explanations and you confirmed my understanding.

Now, I just underline lines with  :blink:


 

Related Topics