remove alloca() dependency

This commit is contained in:
seanpringle
2012-10-29 06:45:26 +10:00
parent 0a896a716a
commit 535ea4ee63
2 changed files with 3 additions and 3 deletions

2
spot.c
View File

@@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
void spot_update_bar(int spot, int mon) void spot_update_bar(int spot, int mon)
{ {
int i, n = 0, len = 0; client *o, *c = NULL; int i, n = 0, len = 0; client *o, *c = NULL;
char *title = alloca(SPOT_BUFF); *title = 0; char title[SPOT_BUFF]; *title = 0;
monitor *m = &monitors[mon]; monitor *m = &monitors[mon];
for_windows(i, o) if (o->manage && o->spot == spot && o->monitor == mon) for_windows(i, o) if (o->manage && o->spot == spot && o->monitor == mon)

View File

@@ -95,7 +95,7 @@ void textbox_font(textbox *tb, char *font, char *fg, char *bg)
void textbox_extents(textbox *tb) void textbox_extents(textbox *tb)
{ {
int length = strlen(tb->text) + strlen(tb->prompt); int length = strlen(tb->text) + strlen(tb->prompt);
char *line = alloca(length + 1); char line[length + 1];
sprintf(line, "%s%s", tb->prompt, tb->text); sprintf(line, "%s%s", tb->prompt, tb->text);
XftTextExtents8(display, tb->font, (unsigned char*)line, length, &tb->extents); XftTextExtents8(display, tb->font, (unsigned char*)line, length, &tb->extents);
} }
@@ -190,7 +190,7 @@ void textbox_draw(textbox *tb)
length = text_len + prompt_len; length = text_len + prompt_len;
cursor_offset = MIN(tb->cursor + prompt_len, length); cursor_offset = MIN(tb->cursor + prompt_len, length);
line = alloca(length + 10); char eline[length + 10]; line = eline;
sprintf(line, "%s%s", prompt, text); sprintf(line, "%s%s", prompt, text);
// replace spaces so XftTextExtents8 includes their width // replace spaces so XftTextExtents8 includes their width