git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/7] Add buffer pool library

From
David Michael Barr <david.barr@cordelta.com>
Date
May 29, 2010, 10:55 UTC
Message-ID
<512B4EA0-463F-4CF2-94AB-404BF1BAE229@cordelta.com>
In-Reply-To
<20100529085124.GA6847@progeny.tock>
Ji Jonathan,
Show 5 quoted lines
>> line_buffer creates a couple of static buffers and expose an API for
>> using them.
> 
> So this provides a thread-unsafe fgets() and fread() where the caller
> does not have to supply a buffer.  Sounds convenient.

Very convenient indeed. Its primary reason for existence is to assist debugging the svn dump parser.

> Missing From: line and sign-off.
I'm sure Ram will fix this up in the next rebase.
Show 5 quoted lines
>> +char *buffer_read_line(void)
>> +{
>> +    char *end;
> 
> style nitpick: use tabs to indent.
Will read git style guide and try to match for convenience.
> Why not fgets()?
Historical reasons, can be factored out.
> So if this buffer library is in use, all input needs to pass through
> it?  I would prefer to avoid that if possible.
The design is almost single-caller anyway...
Show 15 quoted lines
>> +        line_len += offset;
>> +    }
>> +    while (offset < len && !feof(stdin)) {
>> +        offset += fread(&s[offset], 1, len - offset, stdin);
>> +    }
> 
> On error, wouldn’t this be an infinite loop?  Maybe:
> 
>  offset += fread(&s[offset], 1, len - offset, stdin);
>  if (ferror(stdin)) {
> 	free(s);
> 	return NULL;
> }
> 
> One iteration should be sufficient, since fread loops internally
Thanks for the tip.

-- David Barr

Previous: Jonathan NiederNext: Ramkumar Ramachandra
Message 13 of 29 in “Import David's SVN exporter”
  1. 0/7 Import David's SVN exporterRamkumar Ramachandra, May 23, 2010
  2. 1/7 Add skeleton remote helper for SVNRamkumar Ramachandra, May 23, 2010
  3. 2/7 Add cpp macro implementation of treapsRamkumar Ramachandra, May 23, 2010
  4. Jonathan NiederMay 29, 2010
  5. Ramkumar RamachandraMay 30, 2010
  6. Jonathan NiederMay 30, 2010
  7. Ramkumar RamachandraMay 30, 2010
  8. 3/7 Add buffer pool libraryRamkumar Ramachandra, May 23, 2010
  9. Peter BaumannMay 24, 2010
  10. Ramkumar RamachandraMay 24, 2010
  11. David Michael BarrMay 24, 2010
  12. Jonathan NiederMay 29, 2010
  13. David Michael BarrMay 29, 2010
  14. 4/7 Add a memory pool libraryRamkumar Ramachandra, May 23, 2010
  15. Jonathan NiederMay 29, 2010
  16. Ramkumar RamachandraMay 30, 2010
  17. Jonathan NiederMay 30, 2010
  18. Ramkumar RamachandraMay 30, 2010
  19. 5/7 Add API for string-specific memory poolRamkumar Ramachandra, May 23, 2010
  20. Jonathan NiederMay 29, 2010
  21. Ramkumar RamachandraMay 30, 2010
  22. Jonathan NiederMay 30, 2010
  23. Ramkumar RamachandraMay 30, 2010
  24. 6/7 Add SVN revision parser and exporterRamkumar Ramachandra, May 23, 2010
  25. Jonathan NiederMay 29, 2010
  26. Ramkumar RamachandraMay 30, 2010
  27. 7/7 Add handler for SVN dumpRamkumar Ramachandra, May 23, 2010
  28. Jonathan NiederMay 30, 2010
  29. Ramkumar RamachandraMay 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.