Skip to content

String api additions, cleanup and docs#2

Open
nick-bors wants to merge 5 commits intomainfrom
cleanup
Open

String api additions, cleanup and docs#2
nick-bors wants to merge 5 commits intomainfrom
cleanup

Conversation

@nick-bors
Copy link
Copy Markdown
Contributor

No description provided.

@nick-bors
Copy link
Copy Markdown
Contributor Author

sorry for the git issue... i couldnt open the old one

Comment thread include/common/str.h Outdated
/// \return string Owned string
///
/// \see clone_to_cstring
string string_clone(string str); // this allocates as well
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can get rid of these old "this allocates as well" side comments, since we're committing to actual doc comments

Comment thread include/common/str.h Outdated
/// Allocates a buffer containing the concatenation of a and b.
///
/// \return str Allocated string containing ab, without a null terminator.
string string_concat(string a, string b); // allocates
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, etc.

Comment thread include/common/vec.h
#define vec_header(vec) ((VecHeader*)((char*)(vec) - sizeof(VecHeader)))
/// Get the pointer to a vec's elements from the header.
#define vec_elems_from_header(header) ((void*)((char*)(header) + sizeof(VecHeader)))
#define vec_elems_from_header(header) ((void*)((u8*)(header) + sizeof(VecHeader)))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary but /shrug

Comment thread src/common/str.c Outdated
char* raw = malloc(len);

memset(raw, '\0', len);
inline string string_alloc(usize len) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functions should either not be inline at all, or inline static and put in the header.

Comment thread src/common/str.c Outdated
}

int string_cmp(string a, string b) {
u8 string_cmp(string a, string b) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this an incorrect signature, should not have been modified in the first place

Comment thread src/common/str.c Outdated
}
return true;
inline bool string_eq(string a, string b) {
return a.len == 0 || (a.len == b.len && string_cmp(a, b) == 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this an incorrect completely, should not have been modified in the first place

Comment thread src/common/str.c Outdated
}

void printstr(string str) {
inline void printstr(string str) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no inline on public functions in a .c file, it should be static inline inside the header or not inline at all

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