Hacker Newsnew | past | comments | ask | show | jobs | submit | aheck's commentslogin

One of the great strengths of strace as a debugging tool is that it shows you what a program is doing regardless of whether it was compiled with debug info or not. The downside of this is that you only see the program’s syscall. You can use this information to deduce what is happening in the program but you don’t see from where in the program those syscalls originate...


Why did you just quote the start of the article?


He's the person that submitted the post. I assume he added it for context.


Thanks for pointing this out, I just replaced it with exit(1).


You're right, calling exit when out of memory is at least controversial if not even bad. I still do it because the goal is to be source compatible with GLib. And this is how GLib handles out of memory, unfortunately.

https://libsoup.org/glib/glib-Memory-Allocation.html#g-mallo...

https://stackoverflow.com/questions/16974254/glib-handle-out...

Thanks for pointing out the null termination issue. This was actually a bug and I just fixed it in g_string_append_len. The other _len methods look fine to me.

Since CLib aims to be source compatible with GLib the documentation for the respective classes of GLib should do it:

https://libsoup.org/glib/glib-Strings.html

https://libsoup.org/glib/glib-Hash-Tables.html

https://libsoup.org/glib/glib-Doubly-Linked-Lists.html


I had no idea GLib did that. Their string implementation seems to be the best one to use, too, for those looking for a capacity, length, and data implementation. I'm a bit disappointed to know this now. But good on you for being strictly compatible; I feel like many people would fudge the implementation.

Thanks for sharing this.


Yeah, the GLib documentation is not very good at pointing this out, unfortunately.

I'm also thinking about maybe creating a slightly incompatible version which might use "c_" as a prefix instead of "g_". There would also need to be some changes to the interface and not only the return values because the methods that do a realloc internally only return a pointer to the object itself (e.g. GString*) for chaining and therefore cannot be used to signal an error condition.

But not sure, yet if this is a good idea or just creates confusion.

For the moment I just want to provide the (in my opinion) by far most important classes of GLib because I always missed something like that in the C standard library. This is also why I chose to implement it header-only. It should be as easy as possbile for people to use them.

The out of memory handling is very unfortunate and you should probably not use this code in the middle of a database transaction or something similar but I think for most user level code and situations where you would handle out of memory with exit anyway it is ok as it is.


Thanks for your feedback!

1) The pricing is 29.95 Euro and the license will be valid for all 1.x versions and there is no subscription. There are no plans for a 2.x at this point in time. Instead there are plans for quite a bunch of 1.x versions in the coming years to improve the product continually. But you are right. I will make this more clear on website.

2) I will look into this. Which iPhone are you using?


iPhone 12 mini


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: