Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

X #868

Closed
wants to merge 9 commits into from
Closed

X #868

wants to merge 9 commits into from

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Dec 5, 2023

Not Twitter. The other x.

Continuing the series of generalizing APIs and reducing specialized functions, kill all x*() functions, and add a generic x() macro that can be chained to any "standard" call, that is, any call that reports errors via -1 (for integers) or NULL (for pointers).

Instead of xasprintf(), now we'll x(asprintf()). Instead of xstrdup(), x(strdup()).

@alejandro-colomar alejandro-colomar force-pushed the x branch 17 times, most recently from a71f59a to 34b251f Compare December 5, 2023 16:46
@alejandro-colomar alejandro-colomar marked this pull request as ready for review December 5, 2023 16:53
And move some from "must_be.h" to the new header "typetraits.h", and
reimplement them in terms of the new macros.

Signed-off-by: Alejandro Colomar <[email protected]>
Writing an x*() variant of several functions is unnecessary.  It's
simpler to write a generic x() macro that can be chained with any other
calls.

For example:

	-  x(malloc(...)) instead of xmalloc(...);
	-  x(strdup(...)) instead of xstrdup(...);

This requires that we use a very strict and consistent convention of
signaling errors.  For pointers, the obvious way is NULL.  For integers,
it's -1.

If an error is detected, log an error, and exit(13).  About why 13, I
don't really know.  It's just what was used previously in xmalloc().

Signed-off-by: Alejandro Colomar <[email protected]>
…se its test to test now x()

Signed-off-by: Alejandro Colomar <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant