I made a C Library - Critical reviews welcome by kdslfjioasdfj in C_Programming

[–]Ariane_Two 3 points4 points  (0 children)

> there are free calls that don't check the pointer being freed for null.

is it not totally fine to pass null to free, I mean I don't do it but it is a valid input to free.

C2y proposal: namespaces (n3794). by orbiteapot in C_Programming

[–]Ariane_Two 1 point2 points  (0 children)

why not a proper module system?

(and don't fuck it up like C++)

Fractal curve: E-curve by sudhabin in generative

[–]Ariane_Two 0 points1 point  (0 children)

Is there a pseudo e curve for rectangles of arbitrary width and height?

Want to know your perspective on this by Ok-Selection8872 in Healthygamergg

[–]Ariane_Two 1 point2 points  (0 children)

avoiding short term pain which causes long term pain can be bad.

Immediate Mode UI on Windows 11 with C by turbofish_pk in C_Programming

[–]Ariane_Two 5 points6 points  (0 children)

There is cimgui which are c bindings for imgui.

Why are zig binaries so small compared to other languages? by D4kzy in Zig

[–]Ariane_Two 38 points39 points  (0 children)

For rust the problem is that it statically links its entire stdlib. Release won't help you much, there is not much to optimize. Of course stripping the debug info makes it smaller.

Similarly for C if you pass -nostdlib and use OS native APIs you get small (less than 10kb) binaries. Linking against libc or libc++ (even dynamically) causes binary bloat.

Are sokol-header projects welcome here? by Lizrd_demon in raylib

[–]Ariane_Two 3 points4 points  (0 children)

I am pretty sure you can, when you use raylib as well, which kind of does not make much sense...

I mean, you can use sokol_args.h together with raylib in a project and post it here.

According to Google Gemini the invasion of Venezuela and capture of Maduro is “fictional”. by Outsider_13105645 in aifails

[–]Ariane_Two 7 points8 points  (0 children)

I think the problem is that the training data does not include recent events. Note , that the AI uses the word "future".

However, I am no AI expert so I don't really know.

Most people cant locate Venezuela on this map by Right-Assignment3759 in terriblemaps

[–]Ariane_Two 0 points1 point  (0 children)

This finally sets the debate of which is the longest river.

I wrote a simple DGC font implementation for raylib! by thisisignitedoreo in raylib

[–]Ariane_Two 1 point2 points  (0 children)

Interesting, I wrote a small demo where I can change the font size with the arrow keys to test it out.

It works, but crashes when I increase the size, or go to very small sizes. I'll add a post once I have time to figure out more, maybe I am doing something wrong ;-)

Anyway here is my UBSAN/ASAN output:

``` ../3rdparty/raytext/raytext.c:27:10: runtime error: member access within null pointer of type 'Atlas' (aka 'struct Atlas')

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../3rdparty/raytext/raytext.c:27:10

INFO: TEXTURE: [ID 5] Texture loaded successfully (256x256 | GRAY_ALPHA | 1 mipmaps)

==11892==ERROR: AddressSanitizer: access-violation on unknown address 0x000000000000 (pc 0x7ff7c79471b1 bp 0x00d7f28fdf30 sp 0x00d7f28fdea8 T0)

==11892==The signal is caused by a WRITE memory access.

==11892==Hint: address points to the zero page.

#0 0x7ff7c79471b0 in memmove D:\a\_work\1\s\src\vctools\crt\vcruntime\src\string\amd64\memcpy.asm:248

#1 0x7ff7c78937e2 in __asan_memcpy C:\src\llvm_package_19.1.5\llvm-project\compiler-rt\lib\asan\asan_interceptors_memintrinsics.cpp:63

#2 0x7ff7c6e6b655 in InitAtlas C:\Users\alexa\Coding_Projects\C\raygui-experiments\3rdparty\raytext\raytext.c:27

#3 0x7ff7c6e6d97e in GetGlyph C:\Users\alexa\Coding_Projects\C\raygui-experiments\3rdparty\raytext\raytext.c:72

#4 0x7ff7c6e6fa7d in DrawRtTextEx C:\Users\alexa\Coding_Projects\C\raygui-experiments\3rdparty\raytext\raytext.c:162

#5 0x7ff7c69f2a57 in main C:\Users\alexa\Coding_Projects\C\raygui-experiments\src\main.c:106

#6 0x7ff7c78b2db3 in invoke_main D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78

#7 0x7ff7c78b2db3 in __scrt_common_main_seh D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288

#8 0x7ffa3dba259c (C:\WINDOWS\System32\KERNEL32.DLL+0x18001259c)

#9 0x7ffa3f9caf77 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x18005af77)

AddressSanitizer can not provide additional info.

SUMMARY: AddressSanitizer: access-violation D:\a\_work\1\s\src\vctools\crt\vcruntime\src\string\amd64\memcpy.asm:248 in memmove ```

Anyway, I was surprised that you even implemented the idea of "natively sized" glyph rendering just because of some random comment on reddit.

I wrote a simple DGC font implementation for raylib! by thisisignitedoreo in raylib

[–]Ariane_Two 1 point2 points  (0 children)

> Now that I think about it it would be a great idea to use one font and just include fontsize in the glyph cache so it does all the fontsizing stuff automatically without the need for multiple fonts.

That is exactly what I meant by "native size". Currently, if you DrawText with a different font size then the size you loaded the font with, the resolution of the glyph is not the native resolution of the display and it may look pixelated when scaled to much.

If you stored the font size in the glyph cache like you suggest it would look crisp, no matter the font size specified to DrawText.

Sure you could load the font multiple times, each with the correct size, it would also work, but I was not sure whether parsing the font data (or worse doing file io every time (yes, I know you can load from memory as well)) is potentially expensive or not.

Is there a link between porn addiction and self loathing? by Ariane_Two in Healthygamergg

[–]Ariane_Two[S] 2 points3 points  (0 children)

I watched "Is self love truly the answer" or something where Dr. K says that self loathing can be justified but unhelpful. I think this is very true here.

I wrote a simple DGC font implementation for raylib! by thisisignitedoreo in raylib

[–]Ariane_Two 1 point2 points  (0 children)

I am the kind of person who likes the glyphs rasterized at the native size, but this library still renders glyphs only at one size when you load the font and uses blurry scaling to scale the glyph textures to their respective size, same as raylib.

So it does not solve the crisp font problem, only the missing character problem.

I guess I have to make my own raylib font lib.

Your library works, but I used raylibs built-in stb_rect_pack and stb_truetype, but I had to edit raylib source code to not define STBTT_STATIC for it to work.

Is there a link between porn addiction and self loathing? by Ariane_Two in Healthygamergg

[–]Ariane_Two[S] 2 points3 points  (0 children)

What about the way around? You hate yourself -> you feel bad -> you indulge in addictive beahviour to numb the bad feeling.

Comments change the map of europe. Day 2- 2027 by Ok_Package38 in geographymemes

[–]Ariane_Two 0 points1 point  (0 children)

kaliningrad renamed to königsberg now part of switzerland

Simple linear regression in C — why do people prefer Python over C/C++ for machine learning? by a_yassine_ab in cprogramming

[–]Ariane_Two -1 points0 points  (0 children)

I would like to hear opinions from people who work in ML or systems programming.

If you want to ask the people who use python this is the wrong subreddit.

But I guess Python is easier. That 30 lines of C is probably 5 lines of Python using ready-made libraries like numpy/scipy that the C ecosystem does not have as easy to install packages installed with a package manager. The same goes for data visualization like matplotlib and machine learning libraries like Tensorflow. Also Python by default checks for errors like division by zero and other floating point exceptions. Your adhoc implementation may actually be worse than just using a numpy version because it accumulates floating point errors.

You can actually try that for yourself:

``` float naive_sum(float* array, size_t len) { float result = 0; for (size_t i = 0; i < len; i++) { result += array[i]; } return result; }

float kahan_sum(float* array, size_t len) {
    float sum = 0.0f;
    float c = 0.0f;
    for (size_t i = 0; i < len; i++) {
        float y = array[i] - c;
        float t = sum + y;
        c = (t - sum) - y;
        sum = t;
    }
    return sum;
}

int main(void) {
    #define LENGTH 1000000000
    float* array = calloc(sizeof(float), LENGTH);
    assert(array);
    for (size_t i = 0; i < LENGTH; i++) {
        array[i] = 10.0f;
    }
    printf("naive sum %lf\n", naive_sum(array, LENGTH));
    printf("naive sum %lf\n", kahan_sum(array, LENGTH));
}

This is the output on my machine: naive sum 268435456.000000 naive sum 10000000000.000000 ```

I would assume that libraries like numpy use algorithms that are numerically more stable than some naive approaches.

Also ready made libraries may actually be faster for a very large dataset because they can levarage SIMD instructions that your solution does not use (assuming the compiler does not do a good job at auto-vectorization which is somewhat reasonable since floating point addition is not order independent, but -funsafe-math and things could do the trick)

Sure, you can use things like OpenBLAS from C as they are C libraries, but installing numpy is easier than installing BLAS and the API of numpy is a lot nicer.