diff options
author | Michael McConville <mmcconville@mykolab.com> | 2015-12-08 21:00:39 -0500 |
---|---|---|
committer | Will Estes <westes575@gmail.com> | 2015-12-09 09:48:39 -0500 |
commit | c53d722b0b4e81b08cfc2f9ff6675a7abe0de2c3 (patch) | |
tree | 4e19f81d30f1b2323c0a89a09c0d92359e713634 /src/buf.c | |
parent | c03bef5411d3231f42445932d1971d656f020817 (diff) |
Removed flex_alloc; cleaned up style.
The function flex_alloc() was just a wrapper around malloc(). Since this only added unclarity, and the flex_alloc() function is likely a legacy of olden times, remove it in favor of calls to malloc() directly.
Style elements cleaned up:
* superfluous spacing around parentheses
* non-constant initialization in variable declarations
* needless casts
* almost all uses of assignments as subexpressions
Diffstat (limited to 'src/buf.c')
-rw-r--r-- | src/buf.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -73,7 +73,8 @@ struct Buf *buf_prints (struct Buf *buf, const char *fmt, const char *s) char *t; size_t tsz; - t = flex_alloc (tsz = strlen (fmt) + strlen (s) + 1); + tsz = strlen(fmt) + strlen(s) + 1; + t = malloc(tsz); if (!t) flexfatal (_("Allocation of buffer to print string failed")); snprintf (t, tsz, fmt, s); @@ -93,7 +94,7 @@ struct Buf *buf_linedir (struct Buf *buf, const char* filename, int lineno) char *dst, *t; const char *src; - t = flex_alloc (strlen ("#line \"\"\n") + /* constant parts */ + t = malloc(strlen("#line \"\"\n") + /* constant parts */ 2 * strlen (filename) + /* filename with possibly all backslashes escaped */ (int) (1 + log10 (abs (lineno))) + /* line number */ 1); /* NUL */ @@ -165,7 +166,8 @@ struct Buf *buf_m4_define (struct Buf *buf, const char* def, const char* val) size_t strsz; val = val?val:""; - str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + strlen(val) + 2); + strsz = strlen(fmt) + strlen(def) + strlen(val) + 2; + str = malloc(strsz); if (!str) flexfatal (_("Allocation of buffer for m4 def failed")); @@ -185,7 +187,8 @@ struct Buf *buf_m4_undefine (struct Buf *buf, const char* def) char * str; size_t strsz; - str = (char*)flex_alloc(strsz = strlen(fmt) + strlen(def) + 2); + strsz = strlen(fmt) + strlen(def) + 2; + str = malloc(strsz); if (!str) flexfatal (_("Allocation of buffer for m4 undef failed")); |