diff options
| author | Gerd Moellmann | 2001-01-22 11:52:45 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-01-22 11:52:45 +0000 |
| commit | 57b4c82e8ef842d11893173ec2a3c0d5dda1a277 (patch) | |
| tree | cb410cc0a8be659bde903629c4e9f589fb4d87fa /lib-src | |
| parent | 46daf6c74713ab316cf4f6e701c526175a75ff44 (diff) | |
| download | emacs-57b4c82e8ef842d11893173ec2a3c0d5dda1a277.tar.gz emacs-57b4c82e8ef842d11893173ec2a3c0d5dda1a277.zip | |
(xfree): New function.
(member, declaration, globals): Use xmalloc instead of alloca.
Diffstat (limited to 'lib-src')
| -rw-r--r-- | lib-src/ebrowse.c | 52 |
1 files changed, 41 insertions, 11 deletions
diff --git a/lib-src/ebrowse.c b/lib-src/ebrowse.c index 629c8a91045..5a9f155805c 100644 --- a/lib-src/ebrowse.c +++ b/lib-src/ebrowse.c | |||
| @@ -478,6 +478,7 @@ void add_member_decl P_ ((struct sym *, char *, char *, int, | |||
| 478 | unsigned, int, int, int, int)); | 478 | unsigned, int, int, int, int)); |
| 479 | void dump_roots P_ ((FILE *)); | 479 | void dump_roots P_ ((FILE *)); |
| 480 | void *xmalloc P_ ((int)); | 480 | void *xmalloc P_ ((int)); |
| 481 | void xfree P_ ((void *)); | ||
| 481 | void add_global_defn P_ ((char *, char *, int, unsigned, int, int, int)); | 482 | void add_global_defn P_ ((char *, char *, int, unsigned, int, int, int)); |
| 482 | void add_global_decl P_ ((char *, char *, int, unsigned, int, int, int)); | 483 | void add_global_decl P_ ((char *, char *, int, unsigned, int, int, int)); |
| 483 | void add_define P_ ((char *, char *, int)); | 484 | void add_define P_ ((char *, char *, int)); |
| @@ -571,6 +572,17 @@ xrealloc (p, sz) | |||
| 571 | } | 572 | } |
| 572 | 573 | ||
| 573 | 574 | ||
| 575 | /* Like free but always check for null pointers.. */ | ||
| 576 | |||
| 577 | void | ||
| 578 | xfree (p) | ||
| 579 | void *p; | ||
| 580 | { | ||
| 581 | if (p) | ||
| 582 | free (p); | ||
| 583 | } | ||
| 584 | |||
| 585 | |||
| 574 | /* Like strdup, but print an error and exit if not enough memory is | 586 | /* Like strdup, but print an error and exit if not enough memory is |
| 575 | available.. If S is null, return null. */ | 587 | available.. If S is null, return null. */ |
| 576 | 588 | ||
| @@ -2572,9 +2584,9 @@ member (cls, vis) | |||
| 2572 | break; | 2584 | break; |
| 2573 | 2585 | ||
| 2574 | case IDENT: | 2586 | case IDENT: |
| 2575 | /* Remember IDENTS seen so far. Among these will be the member | 2587 | /* Remember IDENTS seen so far. Among these will be the member |
| 2576 | name. */ | 2588 | name. */ |
| 2577 | id = (char *) alloca (strlen (yytext) + 2); | 2589 | id = (char *) xrealloc (id, strlen (yytext) + 2); |
| 2578 | if (tilde) | 2590 | if (tilde) |
| 2579 | { | 2591 | { |
| 2580 | *id = '~'; | 2592 | *id = '~'; |
| @@ -2586,7 +2598,11 @@ member (cls, vis) | |||
| 2586 | break; | 2598 | break; |
| 2587 | 2599 | ||
| 2588 | case OPERATOR: | 2600 | case OPERATOR: |
| 2589 | id = operator_name (&sc); | 2601 | { |
| 2602 | char *s = operator_name (&sc); | ||
| 2603 | id = (char *) xrealloc (id, strlen (s) + 1); | ||
| 2604 | strcpy (id, s); | ||
| 2605 | } | ||
| 2590 | break; | 2606 | break; |
| 2591 | 2607 | ||
| 2592 | case '(': | 2608 | case '(': |
| @@ -2616,7 +2632,8 @@ member (cls, vis) | |||
| 2616 | 2632 | ||
| 2617 | if (LOOKING_AT ('{') && id && cls) | 2633 | if (LOOKING_AT ('{') && id && cls) |
| 2618 | add_member_defn (cls, id, regexp, pos, hash, 0, sc, flags); | 2634 | add_member_defn (cls, id, regexp, pos, hash, 0, sc, flags); |
| 2619 | 2635 | ||
| 2636 | xfree (id); | ||
| 2620 | id = NULL; | 2637 | id = NULL; |
| 2621 | sc = SC_MEMBER; | 2638 | sc = SC_MEMBER; |
| 2622 | break; | 2639 | break; |
| @@ -2694,6 +2711,8 @@ member (cls, vis) | |||
| 2694 | skip_matching (); | 2711 | skip_matching (); |
| 2695 | print_info (); | 2712 | print_info (); |
| 2696 | } | 2713 | } |
| 2714 | |||
| 2715 | xfree (id); | ||
| 2697 | } | 2716 | } |
| 2698 | 2717 | ||
| 2699 | 2718 | ||
| @@ -3111,7 +3130,10 @@ declaration (flags) | |||
| 3111 | /* This is for the case `STARTWRAP class X : ...' or | 3130 | /* This is for the case `STARTWRAP class X : ...' or |
| 3112 | `declare (X, Y)\n class A : ...'. */ | 3131 | `declare (X, Y)\n class A : ...'. */ |
| 3113 | if (id) | 3132 | if (id) |
| 3114 | return; | 3133 | { |
| 3134 | xfree (id); | ||
| 3135 | return; | ||
| 3136 | } | ||
| 3115 | 3137 | ||
| 3116 | case '=': | 3138 | case '=': |
| 3117 | /* Assumed to be the start of an initialization in this context. | 3139 | /* Assumed to be the start of an initialization in this context. |
| @@ -3120,7 +3142,11 @@ declaration (flags) | |||
| 3120 | break; | 3142 | break; |
| 3121 | 3143 | ||
| 3122 | case OPERATOR: | 3144 | case OPERATOR: |
| 3123 | id = operator_name (&sc); | 3145 | { |
| 3146 | char *s = operator_name (&sc); | ||
| 3147 | id = (char *) xrealloc (id, strlen (s) + 1); | ||
| 3148 | strcpy (id, s); | ||
| 3149 | } | ||
| 3124 | break; | 3150 | break; |
| 3125 | 3151 | ||
| 3126 | case T_INLINE: | 3152 | case T_INLINE: |
| @@ -3132,7 +3158,7 @@ declaration (flags) | |||
| 3132 | MATCH (); | 3158 | MATCH (); |
| 3133 | if (LOOKING_AT (IDENT)) | 3159 | if (LOOKING_AT (IDENT)) |
| 3134 | { | 3160 | { |
| 3135 | id = (char *) alloca (strlen (yytext) + 2); | 3161 | id = (char *) xrealloc (id, strlen (yytext) + 2); |
| 3136 | *id = '~'; | 3162 | *id = '~'; |
| 3137 | strcpy (id + 1, yytext); | 3163 | strcpy (id + 1, yytext); |
| 3138 | MATCH (); | 3164 | MATCH (); |
| @@ -3194,6 +3220,8 @@ declaration (flags) | |||
| 3194 | 3220 | ||
| 3195 | if (!cls && id && LOOKING_AT ('{')) | 3221 | if (!cls && id && LOOKING_AT ('{')) |
| 3196 | add_global_defn (id, regexp, pos, hash, 0, sc, flags); | 3222 | add_global_defn (id, regexp, pos, hash, 0, sc, flags); |
| 3223 | |||
| 3224 | xfree (id); | ||
| 3197 | id = NULL; | 3225 | id = NULL; |
| 3198 | break; | 3226 | break; |
| 3199 | } | 3227 | } |
| @@ -3231,6 +3259,8 @@ declaration (flags) | |||
| 3231 | skip_matching (); | 3259 | skip_matching (); |
| 3232 | print_info (); | 3260 | print_info (); |
| 3233 | } | 3261 | } |
| 3262 | |||
| 3263 | xfree (id); | ||
| 3234 | } | 3264 | } |
| 3235 | 3265 | ||
| 3236 | 3266 | ||
| @@ -3259,9 +3289,7 @@ globals (start_flags) | |||
| 3259 | 3289 | ||
| 3260 | if (LOOKING_AT (IDENT)) | 3290 | if (LOOKING_AT (IDENT)) |
| 3261 | { | 3291 | { |
| 3262 | char *namespace_name | 3292 | char *namespace_name = xstrdup (yytext); |
| 3263 | = (char *) alloca (strlen (yytext) + 1); | ||
| 3264 | strcpy (namespace_name, yytext); | ||
| 3265 | MATCH (); | 3293 | MATCH (); |
| 3266 | 3294 | ||
| 3267 | if (LOOKING_AT ('=')) | 3295 | if (LOOKING_AT ('=')) |
| @@ -3278,6 +3306,8 @@ globals (start_flags) | |||
| 3278 | leave_namespace (); | 3306 | leave_namespace (); |
| 3279 | MATCH_IF ('}'); | 3307 | MATCH_IF ('}'); |
| 3280 | } | 3308 | } |
| 3309 | |||
| 3310 | xfree (namespace_name); | ||
| 3281 | } | 3311 | } |
| 3282 | } | 3312 | } |
| 3283 | break; | 3313 | break; |