Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
C is a general-purpose computer programming language used for operating systems, games, and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.
-1
votes
Write a function reverse(s) that reverses the character string s. Use it to write a program ...
For your edification, here's a relatively efficient program which fits the exercise and imposes no specific limit in line length nor in number of lines.
A few notes:
The program assumes Linux-style l …
8
votes
Accepted
An Arena/Bump Allocator in C
Note, though, that with the rise of SIMD, many types are now more aligned than max_align_t (which cannot be changed for backward compatibility reason) and thus new C versions provide aligned_alloc instead … Handling of overflow requires some care: using a > b - c rather than a + c > b is better, though that may require proving c <= b first. …
10
votes
Implementing hash table
Your C code is not too bad, however you seem not to know much about hash-tables, and since you requested a performance review, I will focus on a brief (and incomplete) exploration of the various ways of … The best current implementation are Abseil's Swiss Table and Facebook's F14 (for a C++ reference) or Hashbrown (for a Rust reference); they are fairly advanced, complex, and highly-tuned. …
14
votes
Trim leading/trailing space in a string
Document the pre-conditions
C does not specify the encoding of its strings (Latin-1? JS-SHIFT? UTF-8?), so it's up to you to explain which encodings your function support. …
3
votes
Safe(r) / Easier Pointer Allocation Interface in C (ISO C11)
Terminology
There's nothing safe about ShrinkBlockSafe.
If the functionality is thought to be meaningful, I'd urge you to name it according to what the function actually does.
Reallocation
I do think …
17
votes
Accepted
Implementation of C Standard Library Function ntohl()
Unless you wish to optimize the code, with specialized swappers for various hosts orders, you are doing it wrong.
I invite you to check The Byte Order Fallacy by Rob Pike. The punch line: the byte or …
5
votes
Accepted
Implementation of itoa which allocates the string
Memory management and optimization is important.
I will avoid any stylistic remark and focus on this particular aspect of your query.
Memory
First of all, the first rule of optimization is to avoid …