version 1.36, 2019/04/25 17:57:59 |
version 1.37, 2019/04/28 15:03:29 |
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
|
#include <sys/types.h> |
|
|
#include <assert.h> |
#include <assert.h> |
#include <ctype.h> |
#include <ctype.h> |
#include <err.h> |
#include <err.h> |
|
|
#include <string.h> |
#include <string.h> |
#include <unistd.h> |
#include <unistd.h> |
|
|
|
#include "xmalloc.h" |
|
|
/* |
/* |
* Count parent-child element relations in a corpus of DocBook documents. |
* Count parent-child element relations in a corpus of DocBook documents. |
* |
* |
Line 125 table_add(const char *parent, const char *child) |
|
Line 129 table_add(const char *parent, const char *child) |
|
|
|
if (tablei == tablesz) { |
if (tablei == tablesz) { |
tablesz += 64; |
tablesz += 64; |
table = reallocarray(table, tablesz, sizeof(*table)); |
table = xreallocarray(table, tablesz, sizeof(*table)); |
if (table == NULL) |
|
err(1, NULL); |
|
} |
} |
|
|
/* Add a new entry to the table. */ |
/* Add a new entry to the table. */ |
|
|
if ((table[tablei].parent = strdup(parent)) == NULL) |
table[tablei].parent = xstrdup(parent); |
err(1, NULL); |
table[tablei].child = child == NULL ? NULL : xstrdup(child); |
if (child == NULL) |
|
table[tablei].child = NULL; |
|
else if ((table[tablei].child = strdup(child)) == NULL) |
|
err(1, NULL); |
|
table[tablei++].count = init_done ? 1 : -1; |
table[tablei++].count = init_done ? 1 : -1; |
} |
} |
|
|
Line 152 stack_push(const char *name) |
|
Line 150 stack_push(const char *name) |
|
|
|
if (stacki == stacksz) { |
if (stacki == stacksz) { |
stacksz += 8; |
stacksz += 8; |
stack = reallocarray(stack, stacksz, sizeof(*stack)); |
stack = xreallocarray(stack, stacksz, sizeof(*stack)); |
if (stack == NULL) |
|
err(1, NULL); |
|
} |
} |
if ((stack[stacki++] = strdup(name)) == NULL) |
stack[stacki++] = xstrdup(name); |
err(1, NULL); |
|
} |
} |
|
|
/* |
/* |