Conversation
Notices
-
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 06:56:17 JST Construction Worker Going to start writing bigass macros to slightly decrease the amount of writing I need to do in C, lower time complexity
Why do val = (int *) malloc(sizeof(int)) when I can do int_malloc(val, 1)- Pleroma-tan likes this.
- Pleroma-tan repeated this.
-
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 06:56:24 JST Construction Worker cc @kirby uhh thoughts? Pleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 06:56:52 JST Pleroma-tan @MercurialBuilding ew what the fuck
int* a = malloc(sizeof(int));
What are you doing -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 06:58:09 JST Construction Worker @kirby dumbass the right side is a void pointer you need to cast it to an int pointer
And the C version I'm using requires you to declare before assignmentPleroma-tan likes this.Pleroma-tan repeated this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 06:58:15 JST Pleroma-tan @MercurialBuilding okay then that makes more sense -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 07:08:23 JST Pleroma-tan @MercurialBuilding you know I was thinkin
I got away with doing
const char lol[] = "don't modify me!";
char* modify = &lol;
strcpy(modify, "boom");
Wouldn't attempts to access pointer just be treated like accessing the intended type -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 07:10:06 JST Pleroma-tan @MercurialBuilding wait, you're cramming an array of ints into that pointer? -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 07:10:07 JST Construction Worker @kirby what do you mean
You can't modify the array but you can modify what address it points to -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 07:12:44 JST Pleroma-tan @MercurialBuilding oh, then this makes a whole lot more sense -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 07:12:45 JST Construction Worker @kirby yeah bruh
I get a contiguous line of dynamically allocated pointers and can access it like an array. array[1], if array is type Type, is the same as *(*array + sizeof(Type)), IIRC. Mightve gotten my syntax slightly wrong. -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 07:13:32 JST Construction Worker @kirby to make you suffer Pleroma-tan likes this. -
Embed this notice
UsernameSwift ☭ :verifiedaroace: (usernameswift@pleromer.net)'s status on Tuesday, 07-Nov-2023 07:56:06 JST UsernameSwift ☭ :verifiedaroace: 1) You don't need to cast malloc
2) Please tell me that this isn't C89Pleroma-tan likes this.Pleroma-tan repeated this. -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 07:56:35 JST Construction Worker @usernameswift @kirby I think it's C90
I thought I had to cast it, I'll have to try without. Probably will still want to cast when freeingPleroma-tan likes this.Pleroma-tan repeated this. -
Embed this notice
T man :sex: :puffgiga: :puffpowerroll: (theorytoe@ak.kyaruc.moe)'s status on Tuesday, 07-Nov-2023 07:56:43 JST T man :sex: :puffgiga: :puffpowerroll: @MercurialBuilding @kirby
iirc you dont even need to explicitly cast the pointer type???
isnt the type inherited when you memcpy or whenever you copy into storage?Pleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 07:57:06 JST Pleroma-tan @usernameswift @MercurialBuilding yeah uh number 1 is what I was trying to say before. Even without a cast the pointer will still act as a pointer to an int -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 07:58:23 JST Construction Worker @kirby @usernameswift going to kms if the code compiles without needing a cast Pleroma-tan likes this.Pleroma-tan repeated this. -
Embed this notice
UsernameSwift ☭ :verifiedaroace: (usernameswift@pleromer.net)'s status on Tuesday, 07-Nov-2023 07:59:33 JST UsernameSwift ☭ :verifiedaroace: Oh lord
I used to program in C90 sometimes but it's just pain
C99 is so much nicerPleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:01:58 JST Pleroma-tan @navi @MercurialBuilding @usernameswift your indentation fucked up -
Embed this notice
anna (navi@social.vlhl.dev)'s status on Tuesday, 07-Nov-2023 08:02:00 JST anna @usernameswift @MercurialBuilding @kirby you don’t need to cast any pointer to/from void pointers actually.
this is valid and generates no warnings with -Wall -Wpedantic -fanalyzer:
#include <stdio.h> #include <stdlib.h> struct nya { int foo; int bar; }; void nya(void *mew) { struct nya *meow = mew; printf("%d, %d\n", meow->foo, meow->bar); } int main() { struct nya foo = { .foo = 5, .bar = 10 }; nya(&foo); return 0; }so not only malloc, realloc, and free, void* in general are exempt from casts
(but do remember strict aliasing rules. you can’t put a type into a void pointer, and then turn it into another type)
Pleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:03:35 JST Pleroma-tan @navi @MercurialBuilding @usernameswift well husky makes it look like donut.c -
Embed this notice
anna (navi@social.vlhl.dev)'s status on Tuesday, 07-Nov-2023 08:03:36 JST anna @kirby @MercurialBuilding @usernameswift huh, on akkoma it looks alright: Pleroma-tan repeated this. -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 08:04:01 JST Construction Worker @kirby @usernameswift yeah ok I think it worked fuck me
Makefile:
CC=gcc
CFLAGS = -ggdb
CPPFLAGS = -c -std=gnu90 -Wall -pedantic -Wextra
NES = -z noexecstack
mycode.o: mycode.c
$(CC) $(CFLAGS) $(CPPFLAGS) $(NES) -o mycode.o -c mycode.c
mycode: mycode.o
$(CC) $(NES) -o mycode mycode.o
Code:
#include <stdlib.h>
int main(){
int *i;
i = malloc(sizeof(int));
*i = 12;
free(i);
return 0;
}
Compilation Output:
gcc -ggdb -c -std=gnu90 -Wall -pedantic -Wextra -z noexecstack -o mycode.o -c mycode.c
gcc -z noexecstack -o mycode mycode.oPleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:04:25 JST Pleroma-tan @MercurialBuilding @usernameswift see, we told you!!!!!!!!!!!!!!!!!!!!!!! -
Embed this notice
UsernameSwift ☭ :verifiedaroace: (usernameswift@pleromer.net)'s status on Tuesday, 07-Nov-2023 08:04:36 JST UsernameSwift ☭ :verifiedaroace: It looks fine on my end Pleroma-tan likes this. -
Embed this notice
anna (navi@social.vlhl.dev)'s status on Tuesday, 07-Nov-2023 08:04:46 JST anna @kirby some mastodon clients don't support code blocks in markdown
so ye that happens on those :/Pleroma-tan likes this. -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 08:07:30 JST Construction Worker @kirby @usernameswift I don't get it why is it allowed to do type inference Pleroma-tan likes this. -
Embed this notice
pwm (pwm@crlf.ninja)'s status on Tuesday, 07-Nov-2023 08:07:39 JST pwm @kirby @MercurialBuilding @usernameswift @navi use better software Pleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:07:45 JST Pleroma-tan @MercurialBuilding @usernameswift I dunno
I like it tho -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:08:03 JST Pleroma-tan @pwm @MercurialBuilding @usernameswift @navi i probably should husky is a buggy mess -
Embed this notice
pwm (pwm@crlf.ninja)'s status on Tuesday, 07-Nov-2023 08:09:32 JST pwm @kirby @MercurialBuilding @usernameswift @navi pleroma-fe works good on mobile web browsers Pleroma-tan likes this. -
Embed this notice
Construction Worker (mercurialbuilding@cawfee.club)'s status on Tuesday, 07-Nov-2023 08:09:40 JST Construction Worker @kirby @usernameswift I don't it's not explicit Pleroma-tan likes this. -
Embed this notice
Pleroma-tan (kirby@lab.nyanide.com)'s status on Tuesday, 07-Nov-2023 08:10:27 JST Pleroma-tan @pwm @MercurialBuilding @usernameswift @navi I used to do that but pleroma fe on mobile is also a hot mess there are some bugs in it which made it so frustrating to use at some point i got so annoyed I started using husky. -
Embed this notice
pwm (pwm@crlf.ninja)'s status on Tuesday, 07-Nov-2023 08:12:17 JST pwm @kirby @MercurialBuilding @usernameswift @navi just get more ram tbqhfamalamadingdong Pleroma-tan likes this. -
Embed this notice
m0xEE (m0xee@social.librem.one)'s status on Tuesday, 07-Nov-2023 22:18:19 JST m0xEE @kirby
@MercurialBuilding @pwm @usernameswift @navi
PleromaFE is just fine in mobile Firefox if you don't break it by hacks like forcing Firefox fullscreen or CSS injections like I did.
Problem is, there is no fine-grained cookie management in mobile FF — I sure don't want to keep cookies, but I also don't want to log in every fucking time. In Husky/Tusky everything is at least isolated. One day mobile FF will have cookie management and Firefox containers is has in Desktop version — maybe thenPleroma-tan likes this.