yo
On 01/25/11 20:12, Glyn Kennington wrote:
Here's what I've got so far. I've tested the different usages on some
small files of random data (and the multibyte text I was working with
originally), but far from extensively.
I've added a function r_slide to perform the shifting up or down after
the inserted/deleted region. My intention is that this could then be
used by file.insert, when implemented, or another "resize" option that
only moves the bytes around between seek and end-of-block (where the
blocks might be memory pages, or file sections).
the name of the function is wrong. if it's public it should be
r_core_slide()
instead of r_slide(), but i think this function can be 'static' at this
moment.
The thing is that r_slide() should probably take more sense to be in r_io,
renamed as r_io_shift() (shift better than slide?)
Another modification you should do in r_io_shift() is to work in blocks
before mallocing huge chunks in the heap. This is:
- use local ut8 buf[4096]; or malloc to 64k (if you can do some
benchmarks,
we will see which block size is more optimal (4KB, 64KB, etc..)
- loop reading on this block and writing in the shifted address.
This way r_io_slice() will not fail when low memory or huge shiftings.
Those are something I might look into next, but I thought I'd check I'm
not going about this all the wrong way.
Some of my concerns with the attached patch:
* should the adjustment to core->file->size, and reloading the buffer
(where appropriate) be moved inside a file/io-specific resize() method?
core->file->size should be updated after resize(), inside the r_io api
(not in the
specific plugins)
* have I hooked the command up correctly? The way the other commands
use r_cmd_add looks quite straightforward and it seems to work for me,
but there are other bits I don't know if I should touch, such as the
radare_argv array.
yep, the command is hooked perfectly :)
You should add '"r" in the radare_argv array, and write some dummy code
in the
autocomplete() function. but this is just a hack to make autocompletion
work until
we get some time in order to integrate the r_line API with the r_cmd and
being
able to describe the commands and subcommands in a tree structure to display
and autocomplete and display help messages. But this is not going to
happen soon.
Can you resend the patch with those modifications?
Nice patch :) Thanks for the contrib!
btw, I plan to organize a hackaton in february, would you like to
participate?
--pancake
_______________________________________________
radare mailing list
[email protected]
http://lists.nopcode.org/listinfo.cgi/radare-nopcode.org