All Questions
Tagged with comparative-review c
46
questions
3
votes
2
answers
69
views
Reading a file into lines (benchmarking getline() vs mmap_memchr() vs mmap_getline() vs fread())
This is a follow-up to: Reading a file into lines with mmap vs getline.
The actual names of the functions are not ...
7
votes
1
answer
232
views
Reading a file into lines with mmap vs getline
I required a function to read a file into lines for a text editor, and ended up with two routines. One uses getline(), and the other uses ...
5
votes
1
answer
112
views
Instance specific code generation
Disclaimer: I've asked this question before on Stack overflow and got a response that this place would be a better fit so I am copy pasting the question here.
I've come up with two different ...
3
votes
3
answers
101
views
Parse program arguments of the form key=value
I have two proposals for parsing arguments:
Method A
...
2
votes
1
answer
161
views
C/C++ hash looking in flat database compared to PHP
I have a hash table which I would like to query as fast as possible.
The hash table is stored this way :
When I query a hash, I extract first 4 characters then use it to find the file. For instance a ...
3
votes
2
answers
370
views
Retry read/write until all bytes are transferred or error occurs
Currently I have a wrapper function for the read/write system calls, the purpose of which is to eliminate partial transfer ...
0
votes
3
answers
114
views
Populate a color table in XCB
This function has 16 repeated calls to the same function, passing in the same handles to each:
...
2
votes
2
answers
93
views
Common Unit Testing Code – Follow Up
This question is a follow up question to the Common Unit Testing Code portion of my lexical analyzer questions.
My primary concern is the code in the header file and the C source file that implements ...
5
votes
3
answers
382
views
Ask the user a number between 2 and 20
Here is my attempt:
...
4
votes
1
answer
452
views
Evaluating π using Monte Carlo methods - Serial vs OMP
I wrote this simple code for evaluating the π using Monte Carlo method. This is the serial version:
...
7
votes
3
answers
4k
views
malloc in main() or malloc in another function: allocating memory for a struct and its members
When initializing a struct in C, we can allocate memory inside the main function or within another function and return a pointer to the newly created struct. This ...
5
votes
1
answer
323
views
Two cross-platform implementations of getline in C
I created my cross-platform implementations of getline function in C.
It takes different arguments and have different return values than 'original' ...
5
votes
1
answer
320
views
Mouse control of a camera in an OpenGL program
Introduction
I'm doing an OpenGL program in C. As of now I'm working on the 3D camera system and got the control right. Now I'm working on the mouse control.
It works, but I have used two different ...
1
vote
3
answers
95
views
Given a series of characters from stdin, print their squared integer ASCII counterparts
This program in essence is extremely simple, however, it can be written in many different ways. I'm a beginner at C and I've written it in 5 different variations (mostly differing in the use of ...
1
vote
3
answers
546
views
Checking if a string is a palindrome
This is the code for checking if a string is a palindrome. The execution time, for sample cases, is 0.40358 seconds. What must be done to increase the performance?
...