comparison src/regex.c @ 551:e9a3f8b4de53

[xemacs-hg @ 2001-05-21 05:26:06 by martinb] realloc() handling on sunos4; remove lwlib-config kludge
author martinb
date Mon, 21 May 2001 05:26:51 +0000
parents ffd4d00ff0b6
children b39c14581166
comparison
equal deleted inserted replaced
550:1638aacf421d 551:e9a3f8b4de53
129 #ifndef DECLARE_NOTHING 129 #ifndef DECLARE_NOTHING
130 #define DECLARE_NOTHING struct nosuchstruct 130 #define DECLARE_NOTHING struct nosuchstruct
131 #endif 131 #endif
132 #endif 132 #endif
133 133
134 #if defined (STDC_HEADERS) || defined (_LIBC)
135 #include <stdlib.h> 134 #include <stdlib.h>
136 #else
137 char *malloc ();
138 char *realloc ();
139 #endif
140 135
141 #define charptr_emchar(str) ((Emchar) (str)[0]) 136 #define charptr_emchar(str) ((Emchar) (str)[0])
142 137
143 #if (LONGBITS > INTBITS) 138 #if (LONGBITS > INTBITS)
144 # define EMACS_INT long 139 # define EMACS_INT long
367 (size1 && string1 <= (ptr) && (ptr) <= string1 + size1) 362 (size1 && string1 <= (ptr) && (ptr) <= string1 + size1)
368 363
369 /* (Re)Allocate N items of type T using malloc, or fail. */ 364 /* (Re)Allocate N items of type T using malloc, or fail. */
370 #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t))) 365 #define TALLOC(n, t) ((t *) malloc ((n) * sizeof (t)))
371 #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t))) 366 #define RETALLOC(addr, n, t) ((addr) = (t *) realloc (addr, (n) * sizeof (t)))
372 #define RETALLOC_IF(addr, n, t) \
373 if (addr) RETALLOC((addr), (n), t); else (addr) = TALLOC ((n), t)
374 #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t))) 367 #define REGEX_TALLOC(n, t) ((t *) REGEX_ALLOCATE ((n) * sizeof (t)))
375 368
376 #define BYTEWIDTH 8 /* In bits. */ 369 #define BYTEWIDTH 8 /* In bits. */
377 370
378 #define STREQ(s1, s2) (strcmp (s1, s2) == 0) 371 #define STREQ(s1, s2) (strcmp (s1, s2) == 0)
1876 static 1869 static
1877 regex_grow_registers (int num_regs) 1870 regex_grow_registers (int num_regs)
1878 { 1871 {
1879 if (num_regs > regs_allocated_size) 1872 if (num_regs > regs_allocated_size)
1880 { 1873 {
1881 RETALLOC_IF (regstart, num_regs, re_char *); 1874 RETALLOC (regstart, num_regs, re_char *);
1882 RETALLOC_IF (regend, num_regs, re_char *); 1875 RETALLOC (regend, num_regs, re_char *);
1883 RETALLOC_IF (old_regstart, num_regs, re_char *); 1876 RETALLOC (old_regstart, num_regs, re_char *);
1884 RETALLOC_IF (old_regend, num_regs, re_char *); 1877 RETALLOC (old_regend, num_regs, re_char *);
1885 RETALLOC_IF (best_regstart, num_regs, re_char *); 1878 RETALLOC (best_regstart, num_regs, re_char *);
1886 RETALLOC_IF (best_regend, num_regs, re_char *); 1879 RETALLOC (best_regend, num_regs, re_char *);
1887 RETALLOC_IF (reg_info, num_regs, register_info_type); 1880 RETALLOC (reg_info, num_regs, register_info_type);
1888 RETALLOC_IF (reg_dummy, num_regs, re_char *); 1881 RETALLOC (reg_dummy, num_regs, re_char *);
1889 RETALLOC_IF (reg_info_dummy, num_regs, register_info_type); 1882 RETALLOC (reg_info_dummy, num_regs, register_info_type);
1890 1883
1891 regs_allocated_size = num_regs; 1884 regs_allocated_size = num_regs;
1892 } 1885 }
1893 } 1886 }
1894 1887