Fix formatting of comments.

This commit is contained in:
Nick Clifton 2005-05-06 08:49:28 +00:00
parent e06fb9c30f
commit 93a9f99109
3 changed files with 48 additions and 43 deletions

View file

@ -1,3 +1,8 @@
2005-05-06 Nick Clifton <nickc@redhat.com>
* sb.h: Fix formatting of comments.
* sb.c: Fix formatting of comments.
2005-05-06 Jan Beulich <jbeulich@novell.com> 2005-05-06 Jan Beulich <jbeulich@novell.com>
* sb.h (sb_add_buffer): Reintroduce. * sb.h (sb_add_buffer): Reintroduce.

View file

@ -46,9 +46,7 @@
sb_new (&foo); sb_new (&foo);
sb_grow... (&foo,...); sb_grow... (&foo,...);
use foo->ptr[*]; use foo->ptr[*];
sb_kill (&foo); sb_kill (&foo); */
*/
static int dsize = 5; static int dsize = 5;
static void sb_check (sb *, int); static void sb_check (sb *, int);
@ -59,12 +57,12 @@ static int string_count[sb_max_power_two];
/* Free list of sb structures. */ /* Free list of sb structures. */
static sb_list_vector free_list; static sb_list_vector free_list;
/* initializes an sb. */ /* Initializes an sb. */
static void static void
sb_build (sb *ptr, int size) sb_build (sb *ptr, int size)
{ {
/* see if we can find one to allocate */ /* See if we can find one to allocate. */
sb_element *e; sb_element *e;
if (size > sb_max_power_two) if (size > sb_max_power_two)
@ -73,7 +71,7 @@ sb_build (sb *ptr, int size)
e = free_list.size[size]; e = free_list.size[size];
if (!e) if (!e)
{ {
/* nothing there, allocate one and stick into the free list */ /* Nothing there, allocate one and stick into the free list. */
e = (sb_element *) xmalloc (sizeof (sb_element) + (1 << size)); e = (sb_element *) xmalloc (sizeof (sb_element) + (1 << size));
e->next = free_list.size[size]; e->next = free_list.size[size];
e->size = 1 << size; e->size = 1 << size;
@ -81,11 +79,10 @@ sb_build (sb *ptr, int size)
string_count[size]++; string_count[size]++;
} }
/* remove from free list */ /* Remove from free list. */
free_list.size[size] = e->next; free_list.size[size] = e->next;
/* copy into callers world */ /* Copy into callers world. */
ptr->ptr = e->data; ptr->ptr = e->data;
ptr->pot = size; ptr->pot = size;
ptr->len = 0; ptr->len = 0;
@ -98,17 +95,17 @@ sb_new (sb *ptr)
sb_build (ptr, dsize); sb_build (ptr, dsize);
} }
/* deallocate the sb at ptr */ /* Deallocate the sb at ptr. */
void void
sb_kill (sb *ptr) sb_kill (sb *ptr)
{ {
/* return item to free list */ /* Return item to free list. */
ptr->item->next = free_list.size[ptr->pot]; ptr->item->next = free_list.size[ptr->pot];
free_list.size[ptr->pot] = ptr->item; free_list.size[ptr->pot] = ptr->item;
} }
/* add the sb at s to the end of the sb at ptr */ /* Add the sb at s to the end of the sb at ptr. */
void void
sb_add_sb (sb *ptr, sb *s) sb_add_sb (sb *ptr, sb *s)
@ -118,7 +115,7 @@ sb_add_sb (sb *ptr, sb *s)
ptr->len += s->len; ptr->len += s->len;
} }
/* make sure that the sb at ptr has room for another len characters, /* Make sure that the sb at ptr has room for another len characters,
and grow it if it doesn't. */ and grow it if it doesn't. */
static void static void
@ -128,6 +125,7 @@ sb_check (sb *ptr, int len)
{ {
sb tmp; sb tmp;
int pot = ptr->pot; int pot = ptr->pot;
while (ptr->len + len >= 1 << pot) while (ptr->len + len >= 1 << pot)
pot++; pot++;
sb_build (&tmp, pot); sb_build (&tmp, pot);
@ -137,7 +135,7 @@ sb_check (sb *ptr, int len)
} }
} }
/* make the sb at ptr point back to the beginning. */ /* Make the sb at ptr point back to the beginning. */
void void
sb_reset (sb *ptr) sb_reset (sb *ptr)
@ -145,7 +143,7 @@ sb_reset (sb *ptr)
ptr->len = 0; ptr->len = 0;
} }
/* add character c to the end of the sb at ptr. */ /* Add character c to the end of the sb at ptr. */
void void
sb_add_char (sb *ptr, int c) sb_add_char (sb *ptr, int c)
@ -154,7 +152,7 @@ sb_add_char (sb *ptr, int c)
ptr->ptr[ptr->len++] = c; ptr->ptr[ptr->len++] = c;
} }
/* add null terminated string s to the end of sb at ptr. */ /* Add null terminated string s to the end of sb at ptr. */
void void
sb_add_string (sb *ptr, const char *s) sb_add_string (sb *ptr, const char *s)
@ -165,7 +163,7 @@ sb_add_string (sb *ptr, const char *s)
ptr->len += len; ptr->len += len;
} }
/* add string at s of length len to sb at ptr */ /* Add string at s of length len to sb at ptr */
void void
sb_add_buffer (sb *ptr, const char *s, int len) sb_add_buffer (sb *ptr, const char *s, int len)
@ -175,7 +173,7 @@ sb_add_buffer (sb *ptr, const char *s, int len)
ptr->len += len; ptr->len += len;
} }
/* like sb_name, but don't include the null byte in the string. */ /* Like sb_name, but don't include the null byte in the string. */
char * char *
sb_terminate (sb *in) sb_terminate (sb *in)
@ -185,8 +183,8 @@ sb_terminate (sb *in)
return in->ptr; return in->ptr;
} }
/* start at the index idx into the string in sb at ptr and skip /* Start at the index idx into the string in sb at ptr and skip
whitespace. return the index of the first non whitespace character */ whitespace. return the index of the first non whitespace character. */
int int
sb_skip_white (int idx, sb *ptr) sb_skip_white (int idx, sb *ptr)
@ -198,7 +196,7 @@ sb_skip_white (int idx, sb *ptr)
return idx; return idx;
} }
/* start at the index idx into the sb at ptr. skips whitespace, /* Start at the index idx into the sb at ptr. skips whitespace,
a comma and any following whitespace. returns the index of the a comma and any following whitespace. returns the index of the
next character. */ next character. */

View file

@ -28,7 +28,7 @@
#include <stdio.h> #include <stdio.h>
#include "ansidecl.h" #include "ansidecl.h"
/* string blocks /* String blocks
I had a couple of choices when deciding upon this data structure. I had a couple of choices when deciding upon this data structure.
gas uses null terminated strings for all its internal work. This gas uses null terminated strings for all its internal work. This
@ -46,35 +46,37 @@
An sb is allocated by the caller, and is initialized to point to an An sb is allocated by the caller, and is initialized to point to an
sb_element. sb_elements are kept on a free lists, and used when sb_element. sb_elements are kept on a free lists, and used when
needed, replaced onto the free list when unused. needed, replaced onto the free list when unused. */
*/
#define sb_max_power_two 30 /* Don't allow strings more than
2^sb_max_power_two long. */
#define sb_max_power_two 30 /* don't allow strings more than
2^sb_max_power_two long */
/* structure of an sb */
typedef struct sb typedef struct sb
{ {
char *ptr; /* points to the current block. */ char *ptr; /* Points to the current block. */
int len; /* how much is used. */ int len; /* How much is used. */
int pot; /* the maximum length is 1<<pot */ int pot; /* The maximum length is 1<<pot. */
struct le *item; struct le *item;
} }
sb; sb;
/* Structure of the free list object of an sb */ /* Structure of the free list object of a string block. */
typedef struct le typedef struct le
{ {
struct le *next; struct le *next;
int size; int size;
char data[1]; char data[1];
} }
sb_element; sb_element;
/* The free list */ /* The free list. */
typedef struct typedef struct
{ {
sb_element *size[sb_max_power_two]; sb_element *size[sb_max_power_two];
} sb_list_vector; }
sb_list_vector;
extern void sb_new (sb *); extern void sb_new (sb *);
extern void sb_kill (sb *); extern void sb_kill (sb *);