Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=yaxmenu.git;a=commitdiff;h=829b1ec2e1aa6f047e923d28b7ef810ec144c970
commit 829b1ec2e1aa6f047e923d28b7ef810ec144c970 Author: James Buren <r...@frugalware.org> Date: Thu Dec 3 23:23:20 2009 -0600 autostring.h * add static inline function prototypes * hook as_init() initialization into other inline functions * fix as_puts() memory overwrite errors diff --git a/src/autostring.h b/src/autostring.h index 293e2aa..a6e2cda 100644 --- a/src/autostring.h +++ b/src/autostring.h @@ -10,14 +10,22 @@ typedef struct { size_t m; // Maximum position } as_t; +static inline void as_init(as_t *as); +static inline void as_putc(as_t *as,char c); +static inline void as_puts(as_t *as,const char *s); +static inline void as_reset(as_t *as); +static inline void as_compact(as_t *as); +static inline char *as_gets(const as_t *as); +static inline void as_free(const as_t *as); + static inline void as_init(as_t *as) { assert(as); as->s = xnew(char,as->m = AUTOSTRING_INITIAL_LENGTH); - as->p = 0; + as_reset(as); - as->s[as->p++] = '\0'; + as_putc(as,'\0'); } static inline void as_putc(as_t *as,char c) { @@ -32,7 +40,7 @@ static inline void as_putc(as_t *as,char c) { static inline void as_puts(as_t *as,const char *s) { assert(as && s); - if(!as->s[as->p]) + if(!as->s[as->p-1]) --as->p; while(*s) _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git