[2016-01-27 00:54:58 UTC] Wait... having tattoos and piercing shows she has responsibility and is less autistic? Having kids often means you [2016-01-27 00:55:06 UTC] re irresponsible as well. [2016-01-27 00:55:10 UTC] I don't understand the connection. [2016-01-27 00:55:23 UTC] I mean, I'm sure they're great, I just don't think those things have anything to do with it. [2016-01-27 02:12:10 UTC] well it means that there is an incentive for my current lab partner to actually finish our work fast, UNLIKE MY LAST LAB PARTNER WHO'S THE REASON WHY I'M WAY BEHIND ALL MY WORK [2016-01-27 02:14:54 UTC] and yes I did use valgrind, that's how I found the error, basically this is the current code that works: [code] htkv->key = ((HTKeyValue*)iter->node->payload)->key; htkv->value = ((HTKeyValue*)iter->node->payload)->value;[/code] where htkv is passed in the function. The previous code i was trying was [code]HTKeyValue* key_value = malloc(sizeof(HTKeyValue)); GetPayloadIterator(iter, &key_value); *htkv = *key_value;[/code] [2016-01-27 02:14:57 UTC] OOPs [2016-01-27 02:15:49 UTC] but obviously the above does break encapsulation, but i literally tried every combination of malloc and free and retrieving data by NOTHING WORKED [2016-01-27 02:39:03 UTC] ... I just tried: HTKeyValue* cur_element; LLIteratorGetPayload(iter, (LLPayload_t) &cur_element); *htkv = *cur_element; [2016-01-27 02:39:05 UTC] and it works [2016-01-27 02:39:15 UTC] :( without malloc too! [2016-01-27 09:21:29 UTC] I have no idea how or why that breaks encapsulation, but OK [2016-01-27 09:22:59 UTC] What does not using malloc have to do with encapsulation? [2016-01-27 14:14:03 UTC] I'm not saying Python>all other programming languages, but [2016-01-27 17:59:37 UTC] cuz our teacher wants us to seperate out the hashtable from the linkedlist, so we must use the getpayload method instead of directly assigning values... my problem was that i was assuming i needed to malloc something in order to get the payload, instead I just created a local variable on the stack and magically it worked [2016-01-27 21:33:47 UTC] Well you never need to malloc anything, unless: [2016-01-27 21:34:03 UTC] 1) You need the memory to last longer than the function call, and be re-entrant [2016-01-27 21:34:24 UTC] or 2) You need to allocate A LOT of memory and you don't know how much, or it might change [2016-01-27 21:35:48 UTC] there's no encapsulation here in the first place, since you already have access to the internals [2016-01-27 21:36:12 UTC] if it was really encapsulated, you'd have a handle (or similar) and no way to access the internals even if you really wanted to [2016-01-27 21:38:21 UTC] basically, encapsulation is the responsibility of the provider, not the consumer [2016-01-27 21:38:34 UTC] anyone who says otherwise is smoking crack [2016-01-27 21:42:50 UTC] ... [2016-01-27 21:43:28 UTC] I take it getpayload() writes the payload to an address that you specify? [2016-01-27 23:08:45 UTC] yes getpayload does do that, but i suppose it was my fault for reading the spec wrongly: it said "RETURNS A COPY OF THE KEYVALUE BLAH BLAH", so i assumed copy meant we had to malloc and actually copy memory and stuff like that. But all's well, just that i spent probably a bit too long until I figured out that you can create pointers without mallocing them (though I still don't know why it kept on faling when i tried to malloc, then set the return value, then free the malloc in the same function