]> git.cameronkatri.com Git - mandoc.git/blob - mansearch.c
Next speed optimization step for the new apropos(1).
[mandoc.git] / mansearch.c
1 /* $Id: mansearch.c,v 1.27 2014/04/10 02:46:21 schwarze Exp $ */
2 /*
3 * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv>
4 * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 #ifdef HAVE_CONFIG_H
19 #include "config.h"
20 #endif
21
22 #include <assert.h>
23 #include <fcntl.h>
24 #include <getopt.h>
25 #include <limits.h>
26 #include <regex.h>
27 #include <stdio.h>
28 #include <stdint.h>
29 #include <stddef.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33
34 #ifdef HAVE_OHASH
35 #include <ohash.h>
36 #else
37 #include "compat_ohash.h"
38 #endif
39 #include <sqlite3.h>
40
41 #include "mandoc.h"
42 #include "mandoc_aux.h"
43 #include "manpath.h"
44 #include "mansearch.h"
45
46 extern int mansearch_keymax;
47 extern const char *const mansearch_keynames[];
48
49 #define SQL_BIND_TEXT(_db, _s, _i, _v) \
50 do { if (SQLITE_OK != sqlite3_bind_text \
51 ((_s), (_i)++, (_v), -1, SQLITE_STATIC)) \
52 fprintf(stderr, "%s\n", sqlite3_errmsg((_db))); \
53 } while (0)
54 #define SQL_BIND_INT64(_db, _s, _i, _v) \
55 do { if (SQLITE_OK != sqlite3_bind_int64 \
56 ((_s), (_i)++, (_v))) \
57 fprintf(stderr, "%s\n", sqlite3_errmsg((_db))); \
58 } while (0)
59 #define SQL_BIND_BLOB(_db, _s, _i, _v) \
60 do { if (SQLITE_OK != sqlite3_bind_blob \
61 ((_s), (_i)++, (&_v), sizeof(_v), SQLITE_STATIC)) \
62 fprintf(stderr, "%s\n", sqlite3_errmsg((_db))); \
63 } while (0)
64
65 struct expr {
66 uint64_t bits; /* type-mask */
67 const char *substr; /* to search for, if applicable */
68 regex_t regexp; /* compiled regexp, if applicable */
69 int open; /* opening parentheses before */
70 int and; /* logical AND before */
71 int close; /* closing parentheses after */
72 struct expr *next; /* next in sequence */
73 };
74
75 struct match {
76 uint64_t id; /* identifier in database */
77 char *desc; /* manual page description */
78 int form; /* 0 == catpage */
79 };
80
81 static void buildnames(struct manpage *, sqlite3 *,
82 sqlite3_stmt *, uint64_t,
83 const char *, int form);
84 static char *buildoutput(sqlite3 *, sqlite3_stmt *,
85 uint64_t, uint64_t);
86 static void *hash_alloc(size_t, void *);
87 static void hash_free(void *, size_t, void *);
88 static void *hash_halloc(size_t, void *);
89 static struct expr *exprcomp(const struct mansearch *,
90 int, char *[]);
91 static void exprfree(struct expr *);
92 static struct expr *exprspec(struct expr *, uint64_t,
93 const char *, const char *);
94 static struct expr *exprterm(const struct mansearch *, char *, int);
95 static void sql_append(char **sql, size_t *sz,
96 const char *newstr, int count);
97 static void sql_match(sqlite3_context *context,
98 int argc, sqlite3_value **argv);
99 static void sql_regexp(sqlite3_context *context,
100 int argc, sqlite3_value **argv);
101 static char *sql_statement(const struct expr *);
102
103 int
104 mansearch(const struct mansearch *search,
105 const struct manpaths *paths,
106 int argc, char *argv[],
107 const char *outkey,
108 struct manpage **res, size_t *sz)
109 {
110 int fd, rc, c, indexbit;
111 int64_t id;
112 uint64_t outbit, iterbit;
113 char buf[PATH_MAX];
114 char *sql;
115 struct manpage *mpage;
116 struct expr *e, *ep;
117 sqlite3 *db;
118 sqlite3_stmt *s, *s2;
119 struct match *mp;
120 struct ohash_info info;
121 struct ohash htab;
122 unsigned int idx;
123 size_t i, j, cur, maxres;
124
125 memset(&info, 0, sizeof(struct ohash_info));
126
127 info.halloc = hash_halloc;
128 info.alloc = hash_alloc;
129 info.hfree = hash_free;
130 info.key_offset = offsetof(struct match, id);
131
132 *sz = cur = maxres = 0;
133 sql = NULL;
134 *res = NULL;
135 fd = -1;
136 e = NULL;
137 rc = 0;
138
139 if (0 == argc)
140 goto out;
141 if (NULL == (e = exprcomp(search, argc, argv)))
142 goto out;
143
144 outbit = 0;
145 if (NULL != outkey) {
146 for (indexbit = 0, iterbit = 1;
147 indexbit < mansearch_keymax;
148 indexbit++, iterbit <<= 1) {
149 if (0 == strcasecmp(outkey,
150 mansearch_keynames[indexbit])) {
151 outbit = iterbit;
152 break;
153 }
154 }
155 }
156
157 /*
158 * Save a descriptor to the current working directory.
159 * Since pathnames in the "paths" variable might be relative,
160 * and we'll be chdir()ing into them, we need to keep a handle
161 * on our current directory from which to start the chdir().
162 */
163
164 if (NULL == getcwd(buf, PATH_MAX)) {
165 perror(NULL);
166 goto out;
167 } else if (-1 == (fd = open(buf, O_RDONLY, 0))) {
168 perror(buf);
169 goto out;
170 }
171
172 sql = sql_statement(e);
173
174 /*
175 * Loop over the directories (containing databases) for us to
176 * search.
177 * Don't let missing/bad databases/directories phase us.
178 * In each, try to open the resident database and, if it opens,
179 * scan it for our match expression.
180 */
181
182 for (i = 0; i < paths->sz; i++) {
183 if (-1 == fchdir(fd)) {
184 perror(buf);
185 free(*res);
186 break;
187 } else if (-1 == chdir(paths->paths[i])) {
188 perror(paths->paths[i]);
189 continue;
190 }
191
192 c = sqlite3_open_v2
193 (MANDOC_DB, &db,
194 SQLITE_OPEN_READONLY, NULL);
195
196 if (SQLITE_OK != c) {
197 perror(MANDOC_DB);
198 sqlite3_close(db);
199 continue;
200 }
201
202 /*
203 * Define the SQL functions for substring
204 * and regular expression matching.
205 */
206
207 c = sqlite3_create_function(db, "match", 2,
208 SQLITE_ANY, NULL, sql_match, NULL, NULL);
209 assert(SQLITE_OK == c);
210 c = sqlite3_create_function(db, "regexp", 2,
211 SQLITE_ANY, NULL, sql_regexp, NULL, NULL);
212 assert(SQLITE_OK == c);
213
214 j = 1;
215 c = sqlite3_prepare_v2(db, sql, -1, &s, NULL);
216 if (SQLITE_OK != c)
217 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
218
219 for (ep = e; NULL != ep; ep = ep->next) {
220 if (NULL == ep->substr) {
221 SQL_BIND_BLOB(db, s, j, ep->regexp);
222 } else
223 SQL_BIND_TEXT(db, s, j, ep->substr);
224 if (0 == ((TYPE_Nd | TYPE_Nm) & ep->bits))
225 SQL_BIND_INT64(db, s, j, ep->bits);
226 }
227
228 memset(&htab, 0, sizeof(struct ohash));
229 ohash_init(&htab, 4, &info);
230
231 /*
232 * Hash each entry on its [unique] document identifier.
233 * This is a uint64_t.
234 * Instead of using a hash function, simply convert the
235 * uint64_t to a uint32_t, the hash value's type.
236 * This gives good performance and preserves the
237 * distribution of buckets in the table.
238 */
239 while (SQLITE_ROW == (c = sqlite3_step(s))) {
240 id = sqlite3_column_int64(s, 2);
241 idx = ohash_lookup_memory
242 (&htab, (char *)&id,
243 sizeof(uint64_t), (uint32_t)id);
244
245 if (NULL != ohash_find(&htab, idx))
246 continue;
247
248 mp = mandoc_calloc(1, sizeof(struct match));
249 mp->id = id;
250 mp->form = sqlite3_column_int(s, 1);
251 if (TYPE_Nd == outbit)
252 mp->desc = mandoc_strdup(
253 sqlite3_column_text(s, 0));
254 ohash_insert(&htab, idx, mp);
255 }
256
257 if (SQLITE_DONE != c)
258 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
259
260 sqlite3_finalize(s);
261
262 c = sqlite3_prepare_v2(db,
263 "SELECT * FROM mlinks WHERE pageid=?"
264 " ORDER BY sec, arch, name",
265 -1, &s, NULL);
266 if (SQLITE_OK != c)
267 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
268
269 c = sqlite3_prepare_v2(db,
270 "SELECT * FROM keys WHERE pageid=? AND bits & ?",
271 -1, &s2, NULL);
272 if (SQLITE_OK != c)
273 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
274
275 for (mp = ohash_first(&htab, &idx);
276 NULL != mp;
277 mp = ohash_next(&htab, &idx)) {
278 if (cur + 1 > maxres) {
279 maxres += 1024;
280 *res = mandoc_realloc
281 (*res, maxres * sizeof(struct manpage));
282 }
283 mpage = *res + cur;
284 mpage->form = mp->form;
285 buildnames(mpage, db, s, mp->id,
286 paths->paths[i], mp->form);
287 mpage->output = TYPE_Nd & outbit ?
288 mp->desc : outbit ?
289 buildoutput(db, s2, mp->id, outbit) : NULL;
290
291 free(mp);
292 cur++;
293 }
294
295 sqlite3_finalize(s);
296 sqlite3_finalize(s2);
297 sqlite3_close(db);
298 ohash_delete(&htab);
299 }
300 rc = 1;
301 out:
302 exprfree(e);
303 if (-1 != fd)
304 close(fd);
305 free(sql);
306 *sz = cur;
307 return(rc);
308 }
309
310 static void
311 buildnames(struct manpage *mpage, sqlite3 *db, sqlite3_stmt *s,
312 uint64_t id, const char *path, int form)
313 {
314 char *newnames, *prevsec, *prevarch;
315 const char *oldnames, *sep1, *name, *sec, *sep2, *arch, *fsec;
316 size_t i;
317 int c;
318
319 mpage->file = NULL;
320 mpage->names = NULL;
321 prevsec = prevarch = NULL;
322 i = 1;
323 SQL_BIND_INT64(db, s, i, id);
324 while (SQLITE_ROW == (c = sqlite3_step(s))) {
325
326 /* Decide whether we already have some names. */
327
328 if (NULL == mpage->names) {
329 oldnames = "";
330 sep1 = "";
331 } else {
332 oldnames = mpage->names;
333 sep1 = ", ";
334 }
335
336 /* Fetch the next name. */
337
338 sec = sqlite3_column_text(s, 0);
339 arch = sqlite3_column_text(s, 1);
340 name = sqlite3_column_text(s, 2);
341
342 /* If the section changed, append the old one. */
343
344 if (NULL != prevsec &&
345 (strcmp(sec, prevsec) ||
346 strcmp(arch, prevarch))) {
347 sep2 = '\0' == *prevarch ? "" : "/";
348 mandoc_asprintf(&newnames, "%s(%s%s%s)",
349 oldnames, prevsec, sep2, prevarch);
350 free(mpage->names);
351 oldnames = mpage->names = newnames;
352 free(prevsec);
353 free(prevarch);
354 prevsec = prevarch = NULL;
355 }
356
357 /* Save the new section, to append it later. */
358
359 if (NULL == prevsec) {
360 prevsec = mandoc_strdup(sec);
361 prevarch = mandoc_strdup(arch);
362 }
363
364 /* Append the new name. */
365
366 mandoc_asprintf(&newnames, "%s%s%s",
367 oldnames, sep1, name);
368 free(mpage->names);
369 mpage->names = newnames;
370
371 /* Also save the first file name encountered. */
372
373 if (NULL != mpage->file)
374 continue;
375
376 if (form) {
377 sep1 = "man";
378 fsec = sec;
379 } else {
380 sep1 = "cat";
381 fsec = "0";
382 }
383 sep2 = '\0' == *arch ? "" : "/";
384 mandoc_asprintf(&mpage->file, "%s/%s%s%s%s/%s.%s",
385 path, sep1, sec, sep2, arch, name, fsec);
386 }
387 if (SQLITE_DONE != c)
388 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
389 sqlite3_reset(s);
390
391 /* Append one final section to the names. */
392
393 if (NULL != prevsec) {
394 sep2 = '\0' == *prevarch ? "" : "/";
395 mandoc_asprintf(&newnames, "%s(%s%s%s)",
396 mpage->names, prevsec, sep2, prevarch);
397 free(mpage->names);
398 mpage->names = newnames;
399 free(prevsec);
400 free(prevarch);
401 }
402 }
403
404 static char *
405 buildoutput(sqlite3 *db, sqlite3_stmt *s, uint64_t id, uint64_t outbit)
406 {
407 char *output, *newoutput;
408 const char *oldoutput, *sep1, *data;
409 size_t i;
410 int c;
411
412 output = NULL;
413 i = 1;
414 SQL_BIND_INT64(db, s, i, id);
415 SQL_BIND_INT64(db, s, i, outbit);
416 while (SQLITE_ROW == (c = sqlite3_step(s))) {
417 if (NULL == output) {
418 oldoutput = "";
419 sep1 = "";
420 } else {
421 oldoutput = output;
422 sep1 = " # ";
423 }
424 data = sqlite3_column_text(s, 1);
425 mandoc_asprintf(&newoutput, "%s%s%s",
426 oldoutput, sep1, data);
427 free(output);
428 output = newoutput;
429 }
430 if (SQLITE_DONE != c)
431 fprintf(stderr, "%s\n", sqlite3_errmsg(db));
432 sqlite3_reset(s);
433 return(output);
434 }
435
436 /*
437 * Implement substring match as an application-defined SQL function.
438 * Using the SQL LIKE or GLOB operators instead would be a bad idea
439 * because that would require escaping metacharacters in the string
440 * being searched for.
441 */
442 static void
443 sql_match(sqlite3_context *context, int argc, sqlite3_value **argv)
444 {
445
446 assert(2 == argc);
447 sqlite3_result_int(context, NULL != strcasestr(
448 (const char *)sqlite3_value_text(argv[1]),
449 (const char *)sqlite3_value_text(argv[0])));
450 }
451
452 /*
453 * Implement regular expression match
454 * as an application-defined SQL function.
455 */
456 static void
457 sql_regexp(sqlite3_context *context, int argc, sqlite3_value **argv)
458 {
459
460 assert(2 == argc);
461 sqlite3_result_int(context, !regexec(
462 (regex_t *)sqlite3_value_blob(argv[0]),
463 (const char *)sqlite3_value_text(argv[1]),
464 0, NULL, 0));
465 }
466
467 static void
468 sql_append(char **sql, size_t *sz, const char *newstr, int count)
469 {
470 size_t newsz;
471
472 newsz = 1 < count ? (size_t)count : strlen(newstr);
473 *sql = mandoc_realloc(*sql, *sz + newsz + 1);
474 if (1 < count)
475 memset(*sql + *sz, *newstr, (size_t)count);
476 else
477 memcpy(*sql + *sz, newstr, newsz);
478 *sz += newsz;
479 (*sql)[*sz] = '\0';
480 }
481
482 /*
483 * Prepare the search SQL statement.
484 */
485 static char *
486 sql_statement(const struct expr *e)
487 {
488 char *sql;
489 size_t sz;
490 int needop;
491
492 sql = mandoc_strdup("SELECT * FROM mpages WHERE ");
493 sz = strlen(sql);
494
495 for (needop = 0; NULL != e; e = e->next) {
496 if (e->and)
497 sql_append(&sql, &sz, " AND ", 1);
498 else if (needop)
499 sql_append(&sql, &sz, " OR ", 1);
500 if (e->open)
501 sql_append(&sql, &sz, "(", e->open);
502 sql_append(&sql, &sz,
503 TYPE_Nd & e->bits
504 ? (NULL == e->substr
505 ? "desc REGEXP ?"
506 : "desc MATCH ?")
507 : TYPE_Nm == e->bits
508 ? (NULL == e->substr
509 ? "id IN (SELECT pageid FROM names "
510 "WHERE name REGEXP ?)"
511 : "id IN (SELECT pageid FROM names "
512 "WHERE name MATCH ?)")
513 : (NULL == e->substr
514 ? "id IN (SELECT pageid FROM keys "
515 "WHERE key REGEXP ? AND bits & ?)"
516 : "id IN (SELECT pageid FROM keys "
517 "WHERE key MATCH ? AND bits & ?)"), 1);
518 if (e->close)
519 sql_append(&sql, &sz, ")", e->close);
520 needop = 1;
521 }
522
523 return(sql);
524 }
525
526 /*
527 * Compile a set of string tokens into an expression.
528 * Tokens in "argv" are assumed to be individual expression atoms (e.g.,
529 * "(", "foo=bar", etc.).
530 */
531 static struct expr *
532 exprcomp(const struct mansearch *search, int argc, char *argv[])
533 {
534 uint64_t mask;
535 int i, toopen, logic, igncase, toclose;
536 struct expr *first, *prev, *cur, *next;
537
538 first = cur = NULL;
539 logic = igncase = toclose = 0;
540 toopen = 1;
541
542 for (i = 0; i < argc; i++) {
543 if (0 == strcmp("(", argv[i])) {
544 if (igncase)
545 goto fail;
546 toopen++;
547 toclose++;
548 continue;
549 } else if (0 == strcmp(")", argv[i])) {
550 if (toopen || logic || igncase || NULL == cur)
551 goto fail;
552 cur->close++;
553 if (0 > --toclose)
554 goto fail;
555 continue;
556 } else if (0 == strcmp("-a", argv[i])) {
557 if (toopen || logic || igncase || NULL == cur)
558 goto fail;
559 logic = 1;
560 continue;
561 } else if (0 == strcmp("-o", argv[i])) {
562 if (toopen || logic || igncase || NULL == cur)
563 goto fail;
564 logic = 2;
565 continue;
566 } else if (0 == strcmp("-i", argv[i])) {
567 if (igncase)
568 goto fail;
569 igncase = 1;
570 continue;
571 }
572 next = exprterm(search, argv[i], !igncase);
573 if (NULL == next)
574 goto fail;
575 if (NULL == first)
576 first = next;
577 else
578 cur->next = next;
579 prev = cur = next;
580
581 /*
582 * Searching for descriptions must be split out
583 * because they are stored in the mpages table,
584 * not in the keys table.
585 */
586
587 for (mask = TYPE_Nm; mask <= TYPE_Nd; mask <<= 1) {
588 if (mask & cur->bits && ~mask & cur->bits) {
589 next = mandoc_calloc(1,
590 sizeof(struct expr));
591 memcpy(next, cur, sizeof(struct expr));
592 prev->open = 1;
593 cur->bits = mask;
594 cur->next = next;
595 cur = next;
596 cur->bits &= ~mask;
597 }
598 }
599 prev->and = (1 == logic);
600 prev->open += toopen;
601 if (cur != prev)
602 cur->close = 1;
603
604 toopen = logic = igncase = 0;
605 }
606 if (toopen || logic || igncase || toclose)
607 goto fail;
608
609 cur->close++;
610 cur = exprspec(cur, TYPE_arch, search->arch, "^(%s|any)$");
611 exprspec(cur, TYPE_sec, search->sec, "^%s$");
612
613 return(first);
614
615 fail:
616 if (NULL != first)
617 exprfree(first);
618 return(NULL);
619 }
620
621 static struct expr *
622 exprspec(struct expr *cur, uint64_t key, const char *value,
623 const char *format)
624 {
625 char errbuf[BUFSIZ];
626 char *cp;
627 int irc;
628
629 if (NULL == value)
630 return(cur);
631
632 mandoc_asprintf(&cp, format, value);
633 cur->next = mandoc_calloc(1, sizeof(struct expr));
634 cur = cur->next;
635 cur->and = 1;
636 cur->bits = key;
637 if (0 != (irc = regcomp(&cur->regexp, cp,
638 REG_EXTENDED | REG_NOSUB | REG_ICASE))) {
639 regerror(irc, &cur->regexp, errbuf, sizeof(errbuf));
640 fprintf(stderr, "regcomp: %s\n", errbuf);
641 cur->substr = value;
642 }
643 free(cp);
644 return(cur);
645 }
646
647 static struct expr *
648 exprterm(const struct mansearch *search, char *buf, int cs)
649 {
650 char errbuf[BUFSIZ];
651 struct expr *e;
652 char *key, *v;
653 uint64_t iterbit;
654 int i, irc;
655
656 if ('\0' == *buf)
657 return(NULL);
658
659 e = mandoc_calloc(1, sizeof(struct expr));
660
661 /*"whatis" mode uses an opaque string and default fields. */
662
663 if (MANSEARCH_WHATIS & search->flags) {
664 e->substr = buf;
665 e->bits = search->deftype;
666 return(e);
667 }
668
669 /*
670 * If no =~ is specified, search with equality over names and
671 * descriptions.
672 * If =~ begins the phrase, use name and description fields.
673 */
674
675 if (NULL == (v = strpbrk(buf, "=~"))) {
676 e->substr = buf;
677 e->bits = search->deftype;
678 return(e);
679 } else if (v == buf)
680 e->bits = search->deftype;
681
682 if ('~' == *v++) {
683 if (NULL != strstr(buf, "arch"))
684 cs = 0;
685 if (0 != (irc = regcomp(&e->regexp, v,
686 REG_EXTENDED | REG_NOSUB | (cs ? 0 : REG_ICASE)))) {
687 regerror(irc, &e->regexp, errbuf, sizeof(errbuf));
688 fprintf(stderr, "regcomp: %s\n", errbuf);
689 free(e);
690 return(NULL);
691 }
692 } else
693 e->substr = v;
694 v[-1] = '\0';
695
696 /*
697 * Parse out all possible fields.
698 * If the field doesn't resolve, bail.
699 */
700
701 while (NULL != (key = strsep(&buf, ","))) {
702 if ('\0' == *key)
703 continue;
704 for (i = 0, iterbit = 1;
705 i < mansearch_keymax;
706 i++, iterbit <<= 1) {
707 if (0 == strcasecmp(key,
708 mansearch_keynames[i])) {
709 e->bits |= iterbit;
710 break;
711 }
712 }
713 if (i == mansearch_keymax) {
714 if (strcasecmp(key, "any")) {
715 free(e);
716 return(NULL);
717 }
718 e->bits |= ~0ULL;
719 }
720 }
721
722 return(e);
723 }
724
725 static void
726 exprfree(struct expr *p)
727 {
728 struct expr *pp;
729
730 while (NULL != p) {
731 pp = p->next;
732 free(p);
733 p = pp;
734 }
735 }
736
737 static void *
738 hash_halloc(size_t sz, void *arg)
739 {
740
741 return(mandoc_calloc(sz, 1));
742 }
743
744 static void *
745 hash_alloc(size_t sz, void *arg)
746 {
747
748 return(mandoc_malloc(sz));
749 }
750
751 static void
752 hash_free(void *p, size_t sz, void *arg)
753 {
754
755 free(p);
756 }