diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-04-07 14:26:15 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-04-07 14:34:52 -0400 |
commit | 2b087cb45ae91f90492a935625570d7d42ee3ecb (patch) | |
tree | a464213b08d04c8c91c8879a84e534f895c84378 /dimension/lexer.l | |
parent | 7d6663eeb68bf9d0a3dff86128827c0c1d85df69 (diff) | |
download | dimension-2b087cb45ae91f90492a935625570d7d42ee3ecb.tar.xz |
New dmnsn_malloc() function, and friends.
I'm tired of checking for malloc failures everywhere, considering it never
happens. So just bail out whenever it does. A lot of stuff is guaranteed
to succeed if it returns now.
Diffstat (limited to 'dimension/lexer.l')
-rw-r--r-- | dimension/lexer.l | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/dimension/lexer.l b/dimension/lexer.l index 77772ae..89dd7fd 100644 --- a/dimension/lexer.l +++ b/dimension/lexer.l @@ -74,20 +74,14 @@ #define RETURN_VALUE_TOKEN(token_type) \ do { \ NEW_TOKEN(token_type); \ - lvalp->value = strdup(yytext); \ - if (!lvalp->value) \ - dmnsn_error(DMNSN_SEVERITY_HIGH, \ - "Couldn't allocate space for token value."); \ + lvalp->value = dmnsn_strdup(yytext); \ RETURN(); \ } while (0) #define STRING_TOKEN() \ do { \ NEW_TOKEN(DMNSN_T_STRING); \ - lvalp->value = malloc(string_extent); \ - if (!lvalp->value) \ - dmnsn_error(DMNSN_SEVERITY_HIGH, \ - "Couldn't allocate space for token value."); \ + lvalp->value = dmnsn_malloc(string_extent); \ lvalp->value[0] = '\0'; \ CALCULATE_COLUMN(); \ } while (0) @@ -96,10 +90,7 @@ do { \ if (string_length + len + 1 >= string_length) { \ string_extent = 2*(string_length + len + 1); \ - lvalp->value = realloc(lvalp->value, string_extent); \ - if (!lvalp->value) \ - dmnsn_error(DMNSN_SEVERITY_HIGH, \ - "Couldn't allocate space for token value."); \ + lvalp->value = dmnsn_realloc(lvalp->value, string_extent); \ } \ \ strncpy(lvalp->value + string_length, str, len + 1); \ |