libgit-thin: Update some control files
[git/libgit-gsoc.git] / libgit-thin / gsoc-docs / ANSWERS
blobc2c92253a06e75477649739a7568b9f5a5580f1a
1 1. Of course that on a line like 'gcc -o foobar foo.o bar.o' gcc won't do
2 anything more than call the linker right? Then CFLAGS if useless here right?
4  To answer your question about giving gcc object files: if gcc is _not_
5 given the -c flag it produces an executable.  Period.
7  It doesn't matter what you pass it on the command line, it makes an
8 executable.  Now if you give it one or more *.c files it will compile them
9 first.  But if you give it only *.o files and options for the linker it
10 won't need anything that "CFLAGS" (-D/-I/-g/-f) as it won't run the C
11 preprocessor or the C compiler.
13 2. What's exactly the portability issue with 'echo'? Does other unixes
14 doesn't have it? Do they have 'printf'? I'm wondering what POSIX says
15 about that.
17  Wait, what the hell does -e do?  Oh.  It does backslash handling.
18 Oh.  Why do you need to use that here?
20  In general printf is a pass-through to the C library printf()
21 and it doesn't support any command line options.  It also doesn't
22 output an LF, as I'm sure you have learned.  Hence `printf %s ".."`
23 is preferred over `echo -n ".."` as printf is supported on all
24 POSIX systems but `echo -n` is not, as the -n option is not in POSIX.
26  Likewise `echo -e` is not supported on all POSIX systems.  Again,
27 not in POSIX.  So better to avoid it then to rely upon it and then
28 find breakage on non-GNU based systems, aka AIX, Solaris, or a *BSD.
30 3. Why you can't pass a 'const' pointer to free()?
32  You cannot free()' a const'd value, as the free() allows the memory
33 location that pointer is pointing at to be later modified when the C
34 allocator reuses that location.  The compiler is telling you something
35 weird is going on here, and that your code is wrong. This is a good
36 warning to have in your compiler.
38 4. How a missing '\n\n' can be distinguished between a broken commit and
39 an empty log message?
41  You can't. At some point you do have to give up and say "nuts, if you give
42 me bad input, i'll do my best, but i may be wrong".
44 5. Do we have to free the 'commit' pointer returned by
45 lookup_commit_reference_gently()?
47  No. According to Shawn this memory is never freed by the caller, it's
48 up to the SO to release it when the process dies.
50  In his words:
52  """
53  [...] they are wedged in a global hashtable.  hell, odds are the pointer you
54  get back isn't even one known to malloc because its actually in a giant array
55  of them that we alloc'd in large batches.
56  """