/[global]/global/libutil/strbuf.h
ViewVC logotype

Diff of /global/libutil/strbuf.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by shigio, Sun Nov 28 01:04:58 2004 UTC revision 1.8 by shigio, Sat Apr 2 01:27:52 2005 UTC
# Line 56  typedef struct _strbuf { Line 56  typedef struct _strbuf {
56          int alloc_failed;          int alloc_failed;
57  } STRBUF;  } STRBUF;
58    
59    /*
60     * STATIC_STRBUF(sb):
61     *
62     * This macro is used for static string buffer which is suitable for
63     * work area and(or) return value of function. The area allocated once
64     * is repeatedly used though the area is never released.
65     * You must call strbuf_init(sb) every time before using.
66     * You must not call strbuf_close(sb) for it.
67     *
68     * Usage:
69     *      function(...) {
70     *              STATIC_STRBUF(sb);
71     *
72     *              strbuf_init(sb);
73     *              ...
74     *              strbuf_puts(sb, "xxxxx");
75     *              ...
76     *              return strbuf_value(sb);
77     *      }
78     */
79    #define STATIC_STRBUF(sb) static STRBUF __##sb, *sb = &__##sb
80    
81  #define strbuf_putc(sb, c)      do {\  #define strbuf_putc(sb, c)      do {\
82          if (!sb->alloc_failed) {\          if (!sb->alloc_failed) {\
83                  if (sb->curp >= sb->endp)\                  if (sb->curp >= sb->endp)\
# Line 97  void strbuf_dump(char *); Line 119  void strbuf_dump(char *);
119  #endif  #endif
120  void __strbuf_expandbuf(STRBUF *, int);  void __strbuf_expandbuf(STRBUF *, int);
121  STRBUF *strbuf_open(int);  STRBUF *strbuf_open(int);
122    void strbuf_init(STRBUF *);
123  void strbuf_putn(STRBUF *, int);  void strbuf_putn(STRBUF *, int);
124  int strbuf_unputc(STRBUF *, int);  int strbuf_unputc(STRBUF *, int);
125  char *strbuf_value(STRBUF *);  char *strbuf_value(STRBUF *);

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26