*** tpb has joined #timvideos | 00:00 | |
*** tpb has joined #timvideos | 01:07 | |
*** CarlFK has joined #timvideos | 01:10 | |
*** mithro has joined #timvideos | 01:32 | |
Sewar | CarlFK, iiie, mithro: https://dpaste.de/x1haR/ | 01:42 |
---|---|---|
tpb | Title: dpaste.de: Snippet #240028 (at dpaste.de) | 01:42 |
Sewar | ignore 51 for now | 01:42 |
iiie | Sewar, how can I help? | 01:43 |
Sewar | iiie: memset set all new extended bytes in string to NUL so they can be written by strcat | 01:43 |
Sewar | output is updated in parse_edid but in main() it still the same 0 | 01:44 |
iiie | it can be written by strcat | 01:44 |
iiie | even without being set to NULL | 01:44 |
iiie | hm | 01:44 |
CarlFK | Meeting Sep 12 EdX / Rackspace Autoscaling / What's Love Got to do with It? | LIVE: http://www.timvideos.us/chipy | 01:45 |
tpb | Title: Streaming for ChiPy - Chicago Python User Group (at www.timvideos.us) | 01:45 |
iiie | ah | 01:45 |
CarlFK | woo | 01:45 |
Sewar | removing memset breaks things, maybe another line affects it | 01:46 |
iiie | line 50, you're reassigning output I think | 01:46 |
iiie | what breaks skipping the memset? | 01:46 |
iiie | strcat? | 01:46 |
iiie | even though the memset only runs on the destination buffer? | 01:47 |
iiie | hm | 01:47 |
iiie | alright, we're going to try something odd | 01:47 |
Sewar | line 50, yeah, extending its size | 01:47 |
iiie | right, but after that the address of output is different | 01:48 |
Sewar | yeah | 01:49 |
iiie | *output = realloc.... | 01:51 |
iiie | that probably won't work either.... | 01:52 |
Sewar | access violation, because output points to 0 | 01:52 |
iiie | hm | 01:53 |
iiie | what do we want output to be? we want it to be a pointer | 01:53 |
Sewar | yeah | 01:54 |
iiie | so I think we want to change the function signature | 01:54 |
Sewar | let me simplify the code without win stuff | 01:54 |
Sewar | iiie, https://dpaste.de/eLnwh/ | 02:06 |
tpb | Title: dpaste.de: Snippet #240029 (at dpaste.de) | 02:06 |
Sewar | To be clear, what I want to achieve, a char * variable in main(), which I can pass to parse_edid() multiple times so it gets extended, https://dpaste.de/x1haR/#L129 | 02:25 |
tpb | Title: dpaste.de: Snippet #240028 (at dpaste.de) | 02:25 |
iiie | hm | 02:26 |
* iiie is doing too many things at once | 02:27 | |
iiie | I think we want to pass the address of output to test / parser | 02:28 |
iiie | we want the address of the pointer not the pointer itself, because we assign a value to it with realloc | 02:29 |
Sewar | iiie: how to do that? | 02:34 |
iiie | &variable is the address of the variable | 02:35 |
iiie | what does that make the signature though, hm | 02:36 |
iiie | just a minute none windows so I should be able to run it... | 02:38 |
Sewar | https://dpaste.de/eLnwh/ can be compiled and run in linux, I guess | 02:43 |
tpb | Title: dpaste.de: Snippet #240029 (at dpaste.de) | 02:43 |
CarlFK | im off | 02:50 |
*** CarlFK has quit IRC | 02:50 | |
iiie | yeah, so c doesn't support passing by reference, so I think we have to be a little trickier | 02:56 |
iiie | c++ on the other hand | 02:57 |
Sewar | well, the requirement is c right? | 03:02 |
iiie | https://dpaste.de/dwI2F/#L the requirement is binary that works | 03:03 |
tpb | Title: dpaste.de: Snippet #240036 (at dpaste.de) | 03:03 |
iiie | https://dpaste.de/zcmt1/#L | 03:04 |
tpb | Title: dpaste.de: Snippet #240038 (at dpaste.de) | 03:04 |
iiie | this was the result, see how the addresses don't match for outer and inner; that's why we need pass by reference, or to pass the value of the address and cast to what we want. | 03:05 |
Sewar | mmm | 03:09 |
Sewar | http://stackoverflow.com/a/2229510/1957002 | 03:09 |
tpb | Title: pointers - Passing by reference in C - Stack Overflow (at stackoverflow.com) | 03:09 |
iiie | that sounds like it should work then | 03:11 |
iiie | hm | 03:11 |
Sewar | I think there's an incorrect mix of output, &output and *output in the code | 03:13 |
iiie | certainly | 03:13 |
Sewar | http://ideone.com/GU36fH line 15 breaks | 03:24 |
tpb | Title: Ideone.com - GU36fH - Online C Compiler & Debugging Tool (at ideone.com) | 03:24 |
*** mithro has quit IRC | 03:25 | |
iiie | Now there's a cool tool | 03:31 |
Sewar | there's codepad.org too | 03:36 |
*** CarlFK has joined #timvideos | 03:41 | |
*** iiie has quit IRC | 04:19 | |
*** hyades has joined #timvideos | 05:17 | |
hyades | Sewar: you will need something like | 05:43 |
hyades | int test(char **output, int *output_len) | 05:43 |
hyades | http://ideone.com/MoRbnr | 05:45 |
tpb | Title: Ideone.com - MoRbnr - Online C Compiler & Debugging Tool (at ideone.com) | 05:45 |
Sewar | waw, thanks hyades | 06:41 |
hyades | Sewar: btw, I dont think realloc and memset are good things | 06:46 |
hyades | they sometimes dont work as expected | 06:46 |
Sewar | what can I use instead then? | 06:47 |
hyades | free + malloc | 06:59 |
hyades | and for loop :D | 06:59 |
hyades | only malloc will do I guess | 07:01 |
*** CarlFK has quit IRC | 07:21 | |
*** hyades has quit IRC | 11:53 | |
*** CarlFK has joined #timvideos | 12:13 | |
*** skay has quit IRC | 12:56 | |
*** hyades has joined #timvideos | 13:05 | |
*** hyades has quit IRC | 13:25 | |
*** CarlFK has quit IRC | 13:27 | |
*** hyades has joined #timvideos | 13:31 | |
*** hyades has quit IRC | 13:38 | |
*** hyades has joined #timvideos | 14:26 | |
*** hyades_ has joined #timvideos | 14:44 | |
*** hyades_ has quit IRC | 15:23 | |
*** hyades has quit IRC | 15:23 | |
*** hyades has joined #timvideos | 16:14 | |
*** hyades has quit IRC | 17:31 | |
*** hyades has joined #timvideos | 19:33 | |
*** hyades_ has joined #timvideos | 20:03 | |
*** hyades has quit IRC | 21:07 | |
*** hyades_ has quit IRC | 21:08 | |
*** hyades has joined #timvideos | 21:31 | |
*** hyades has quit IRC | 22:35 | |
*** hyades has joined #timvideos | 22:53 |
Generated by irclog2html.py 2.12.1 by Marius Gedminas - find it at mg.pov.lt!