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

trurl: on strdup() failures, exit immediately #324

Merged
merged 1 commit into from
Aug 16, 2024
Merged

Conversation

bagder
Copy link
Member

@bagder bagder commented Aug 16, 2024

Rather than continuing and acting weirdly.

@emanuele6
Copy link
Collaborator

emanuele6 commented Aug 16, 2024

How about a estrdup() wrapper that errors when strdup() returns NULL since we always use the same error message?

@bagder
Copy link
Member Author

bagder commented Aug 16, 2024

I'll get it done!

@bagder bagder force-pushed the bagder/strdup-fails branch 2 times, most recently from e8b2481 to 16140cf Compare August 16, 2024 11:41
Add an xstrdup() version for this purpose.

Rather than continuing and acting weirdly.
@bagder bagder force-pushed the bagder/strdup-fails branch from 16140cf to 3ef3b15 Compare August 16, 2024 15:09
@bagder
Copy link
Member Author

bagder commented Aug 16, 2024

I went with xstrdup() since it seems to be common to use the x prefix for xmalloc() etc for the same general purpose.

@emanuele6
Copy link
Collaborator

emanuele6 commented Aug 16, 2024

I suggested estrdup because it and other e* function are standard in BSD (util.h) and I am familiar with them https://man.netbsd.org/NetBSD-10.0/emalloc.3

But I have also seen x* used with the same meaning in the source code of bash.

@bagder bagder merged commit 53d9998 into master Aug 16, 2024
11 checks passed
@bagder bagder deleted the bagder/strdup-fails branch August 16, 2024 21:29
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.

2 participants