iname.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  1. /* Copyright (C) 1989, 1995, 1997, 1998, 1999 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: iname.c,v 1.7 2003/09/03 03:22:59 giles Exp $ */
  14. /* Name lookup for Ghostscript interpreter */
  15. #include "memory_.h"
  16. #include "string_.h"
  17. #include "ghost.h"
  18. #include "gsstruct.h"
  19. #include "gxobj.h" /* for o_set_unmarked */
  20. #include "ierrors.h"
  21. #include "inamedef.h"
  22. #include "imemory.h" /* for isave.h */
  23. #include "isave.h"
  24. #include "store.h"
  25. /* Public values */
  26. const uint name_max_string = max_name_string;
  27. /* Define the permutation table for name hashing. */
  28. private const byte hash_permutation[256] = {
  29. NAME_HASH_PERMUTATION_DATA
  30. };
  31. /* Define the data for the 1-character names. */
  32. private const byte nt_1char_names[NT_1CHAR_SIZE] = {
  33. NT_1CHAR_NAMES_DATA
  34. };
  35. /* Structure descriptors */
  36. gs_private_st_simple(st_name_sub_table, name_sub_table, "name_sub_table");
  37. gs_private_st_composite(st_name_string_sub_table, name_string_sub_table_t,
  38. "name_string_sub_table_t",
  39. name_string_sub_enum_ptrs, name_string_sub_reloc_ptrs);
  40. gs_private_st_composite(st_name_table, name_table, "name_table",
  41. name_table_enum_ptrs, name_table_reloc_ptrs);
  42. /* Forward references */
  43. private int name_alloc_sub(name_table *);
  44. private void name_free_sub(name_table *, uint);
  45. private void name_scan_sub(name_table *, uint, bool);
  46. /* Debugging printout */
  47. #ifdef DEBUG
  48. private void
  49. name_print(const char *msg, const name_table *nt, uint nidx, const int *pflag)
  50. {
  51. const name_string_t *pnstr = names_index_string_inline(nt, nidx);
  52. const name *pname = names_index_ptr_inline(nt, nidx);
  53. const byte *str = pnstr->string_bytes;
  54. dlprintf1("[n]%s", msg);
  55. if (pflag)
  56. dprintf1("(%d)", *pflag);
  57. dprintf2(" (0x%lx#%u)", (ulong)pname, nidx);
  58. debug_print_string(str, pnstr->string_size);
  59. dprintf2("(0x%lx,%u)\n", (ulong)str, pnstr->string_size);
  60. }
  61. # define if_debug_name(msg, nt, nidx, pflag)\
  62. if ( gs_debug_c('n') ) name_print(msg, nt, nidx, pflag)
  63. #else
  64. # define if_debug_name(msg, nt, nidx, pflag) DO_NOTHING
  65. #endif
  66. /* Initialize a name table */
  67. name_table *
  68. names_init(ulong count, gs_ref_memory_t *imem)
  69. {
  70. gs_memory_t *mem = (gs_memory_t *)imem;
  71. name_table *nt;
  72. int i;
  73. if (count == 0)
  74. count = max_name_count + 1L;
  75. else if (count - 1 > max_name_count)
  76. return 0;
  77. nt = gs_alloc_struct(mem, name_table, &st_name_table, "name_init(nt)");
  78. if (nt == 0)
  79. return 0;
  80. memset(nt, 0, sizeof(name_table));
  81. nt->max_sub_count =
  82. ((count - 1) | nt_sub_index_mask) >> nt_log2_sub_size;
  83. nt->name_string_attrs = imemory_space(imem) | a_readonly;
  84. nt->memory = mem;
  85. /* Initialize the one-character names. */
  86. /* Start by creating the necessary sub-tables. */
  87. for (i = 0; i < NT_1CHAR_FIRST + NT_1CHAR_SIZE; i += nt_sub_size) {
  88. int code = name_alloc_sub(nt);
  89. if (code < 0) {
  90. while (nt->sub_next > 0)
  91. name_free_sub(nt, --(nt->sub_next));
  92. gs_free_object(mem, nt, "name_init(nt)");
  93. return 0;
  94. }
  95. }
  96. for (i = -1; i < NT_1CHAR_SIZE; i++) {
  97. uint ncnt = NT_1CHAR_FIRST + i;
  98. uint nidx = name_count_to_index(ncnt);
  99. name *pname = names_index_ptr_inline(nt, nidx);
  100. name_string_t *pnstr = names_index_string_inline(nt, nidx);
  101. if (i < 0)
  102. pnstr->string_bytes = nt_1char_names,
  103. pnstr->string_size = 0;
  104. else
  105. pnstr->string_bytes = nt_1char_names + i,
  106. pnstr->string_size = 1;
  107. pnstr->foreign_string = 1;
  108. pnstr->mark = 1;
  109. pname->pvalue = pv_no_defn;
  110. }
  111. nt->perm_count = NT_1CHAR_FIRST + NT_1CHAR_SIZE;
  112. /* Reconstruct the free list. */
  113. nt->free = 0;
  114. names_trace_finish(nt, NULL);
  115. return nt;
  116. }
  117. /* Get the allocator for the name table. */
  118. gs_memory_t *
  119. names_memory(const name_table * nt)
  120. {
  121. return nt->memory;
  122. }
  123. /* Look up or enter a name in the table. */
  124. /* Return 0 or an error code. */
  125. /* The return may overlap the characters of the string! */
  126. /* See iname.h for the meaning of enterflag. */
  127. int
  128. names_ref(name_table *nt, const byte *ptr, uint size, ref *pref, int enterflag)
  129. {
  130. name *pname;
  131. name_string_t *pnstr;
  132. uint nidx;
  133. uint *phash;
  134. /* Compute a hash for the string. */
  135. /* Make a special check for 1-character names. */
  136. switch (size) {
  137. case 0:
  138. nidx = name_count_to_index(1);
  139. pname = names_index_ptr_inline(nt, nidx);
  140. goto mkn;
  141. case 1:
  142. if (*ptr < NT_1CHAR_SIZE) {
  143. uint hash = *ptr + NT_1CHAR_FIRST;
  144. nidx = name_count_to_index(hash);
  145. pname = names_index_ptr_inline(nt, nidx);
  146. goto mkn;
  147. }
  148. /* falls through */
  149. default: {
  150. uint hash;
  151. NAME_HASH(hash, hash_permutation, ptr, size);
  152. phash = nt->hash + (hash & (NT_HASH_SIZE - 1));
  153. }
  154. }
  155. for (nidx = *phash; nidx != 0;
  156. nidx = name_next_index(nidx, pnstr)
  157. ) {
  158. pnstr = names_index_string_inline(nt, nidx);
  159. if (pnstr->string_size == size &&
  160. !memcmp_inline(ptr, pnstr->string_bytes, size)
  161. ) {
  162. pname = name_index_ptr_inline(nt, nidx);
  163. goto mkn;
  164. }
  165. }
  166. /* Name was not in the table. Make a new entry. */
  167. if (enterflag < 0)
  168. return_error(e_undefined);
  169. if (size > max_name_string)
  170. return_error(e_limitcheck);
  171. nidx = nt->free;
  172. if (nidx == 0) {
  173. int code = name_alloc_sub(nt);
  174. if (code < 0)
  175. return code;
  176. nidx = nt->free;
  177. }
  178. pnstr = names_index_string_inline(nt, nidx);
  179. if (enterflag == 1) {
  180. byte *cptr = (byte *)gs_alloc_string(nt->memory, size,
  181. "names_ref(string)");
  182. if (cptr == 0)
  183. return_error(e_VMerror);
  184. memcpy(cptr, ptr, size);
  185. pnstr->string_bytes = cptr;
  186. pnstr->foreign_string = 0;
  187. } else {
  188. pnstr->string_bytes = ptr;
  189. pnstr->foreign_string = (enterflag == 0 ? 1 : 0);
  190. }
  191. pnstr->string_size = size;
  192. pname = name_index_ptr_inline(nt, nidx);
  193. pname->pvalue = pv_no_defn;
  194. nt->free = name_next_index(nidx, pnstr);
  195. set_name_next_index(nidx, pnstr, *phash);
  196. *phash = nidx;
  197. if_debug_name("new name", nt, nidx, &enterflag);
  198. mkn:
  199. make_name(pref, nidx, pname);
  200. return 0;
  201. }
  202. /* Get the string for a name. */
  203. void
  204. names_string_ref(const name_table * nt, const ref * pnref /* t_name */ ,
  205. ref * psref /* result, t_string */ )
  206. {
  207. const name_string_t *pnstr = names_string_inline(nt, pnref);
  208. make_const_string(psref,
  209. (pnstr->foreign_string ? avm_foreign | a_readonly :
  210. nt->name_string_attrs),
  211. pnstr->string_size,
  212. (const byte *)pnstr->string_bytes);
  213. }
  214. /* Convert a t_string object to a name. */
  215. /* Copy the executable attribute. */
  216. int
  217. names_from_string(name_table * nt, const ref * psref, ref * pnref)
  218. {
  219. int exec = r_has_attr(psref, a_executable);
  220. int code = names_ref(nt, psref->value.bytes, r_size(psref), pnref, 1);
  221. if (code < 0)
  222. return code;
  223. if (exec)
  224. r_set_attrs(pnref, a_executable);
  225. return code;
  226. }
  227. /* Enter a (permanently allocated) C string as a name. */
  228. int
  229. names_enter_string(name_table * nt, const char *str, ref * pref)
  230. {
  231. return names_ref(nt, (const byte *)str, strlen(str), pref, 0);
  232. }
  233. /* Invalidate the value cache for a name. */
  234. void
  235. names_invalidate_value_cache(name_table * nt, const ref * pnref)
  236. {
  237. pnref->value.pname->pvalue = pv_other;
  238. }
  239. /* Convert between names and indices. */
  240. #undef names_index
  241. name_index_t
  242. names_index(const name_table * nt, const ref * pnref)
  243. {
  244. return names_index_inline(nt, pnref);
  245. }
  246. void
  247. names_index_ref(const name_table * nt, name_index_t index, ref * pnref)
  248. {
  249. names_index_ref_inline(nt, index, pnref);
  250. }
  251. name *
  252. names_index_ptr(const name_table * nt, name_index_t index)
  253. {
  254. return names_index_ptr_inline(nt, index);
  255. }
  256. /* Get the index of the next valid name. */
  257. /* The argument is 0 or a valid index. */
  258. /* Return 0 if there are no more. */
  259. name_index_t
  260. names_next_valid_index(name_table * nt, name_index_t nidx)
  261. {
  262. const name_string_sub_table_t *ssub =
  263. nt->sub[nidx >> nt_log2_sub_size].strings;
  264. const name_string_t *pnstr;
  265. do {
  266. ++nidx;
  267. if ((nidx & nt_sub_index_mask) == 0)
  268. for (;; nidx += nt_sub_size) {
  269. if ((nidx >> nt_log2_sub_size) >= nt->sub_count)
  270. return 0;
  271. ssub = nt->sub[nidx >> nt_log2_sub_size].strings;
  272. if (ssub != 0)
  273. break;
  274. }
  275. pnstr = &ssub->strings[nidx & nt_sub_index_mask];
  276. }
  277. while (pnstr->string_bytes == 0);
  278. return nidx;
  279. }
  280. /* ------ Garbage collection ------ */
  281. /* Unmark all non-permanent names before a garbage collection. */
  282. void
  283. names_unmark_all(name_table * nt)
  284. {
  285. uint si;
  286. name_string_sub_table_t *ssub;
  287. for (si = 0; si < nt->sub_count; ++si)
  288. if ((ssub = nt->sub[si].strings) != 0) {
  289. uint i;
  290. /* We can make the test much more efficient if we want.... */
  291. for (i = 0; i < nt_sub_size; ++i)
  292. if (name_index_to_count((si << nt_log2_sub_size) + i) >=
  293. nt->perm_count)
  294. ssub->strings[i].mark = 0;
  295. }
  296. }
  297. /* Mark a name. Return true if new mark. We export this so we can mark */
  298. /* character names in the character cache. */
  299. bool
  300. names_mark_index(name_table * nt, name_index_t nidx)
  301. {
  302. name_string_t *pnstr = names_index_string_inline(nt, nidx);
  303. if (pnstr->mark)
  304. return false;
  305. pnstr->mark = 1;
  306. return true;
  307. }
  308. /* Get the object (sub-table) containing a name. */
  309. /* The garbage collector needs this so it can relocate pointers to names. */
  310. void /*obj_header_t */ *
  311. names_ref_sub_table(name_table * nt, const ref * pnref)
  312. {
  313. /* When this procedure is called, the pointers from the name table */
  314. /* to the sub-tables may or may not have been relocated already, */
  315. /* so we can't use them. Instead, we have to work backwards from */
  316. /* the name pointer itself. */
  317. return pnref->value.pname - (r_size(pnref) & nt_sub_index_mask);
  318. }
  319. void /*obj_header_t */ *
  320. names_index_sub_table(name_table * nt, name_index_t index)
  321. {
  322. return nt->sub[index >> nt_log2_sub_size].names;
  323. }
  324. void /*obj_header_t */ *
  325. names_index_string_sub_table(name_table * nt, name_index_t index)
  326. {
  327. return nt->sub[index >> nt_log2_sub_size].strings;
  328. }
  329. /*
  330. * Clean up the name table after the trace/mark phase of a garbage
  331. * collection, by removing names that aren't marked. gcst == NULL indicates
  332. * we're doing this for initialization or restore rather than for a GC.
  333. */
  334. void
  335. names_trace_finish(name_table * nt, gc_state_t * gcst)
  336. {
  337. uint *phash = &nt->hash[0];
  338. uint i;
  339. for (i = 0; i < NT_HASH_SIZE; phash++, i++) {
  340. name_index_t prev = 0;
  341. /*
  342. * The following initialization is only to pacify compilers:
  343. * pnprev is only referenced if prev has been set in the loop,
  344. * in which case pnprev is also set.
  345. */
  346. name_string_t *pnprev = 0;
  347. name_index_t nidx = *phash;
  348. while (nidx != 0) {
  349. name_string_t *pnstr = names_index_string_inline(nt, nidx);
  350. name_index_t next = name_next_index(nidx, pnstr);
  351. if (pnstr->mark) {
  352. prev = nidx;
  353. pnprev = pnstr;
  354. } else {
  355. if_debug_name("GC remove name", nt, nidx, NULL);
  356. /* Zero out the string data for the GC. */
  357. pnstr->string_bytes = 0;
  358. pnstr->string_size = 0;
  359. if (prev == 0)
  360. *phash = next;
  361. else
  362. set_name_next_index(prev, pnprev, next);
  363. }
  364. nidx = next;
  365. }
  366. }
  367. /* Reconstruct the free list. */
  368. nt->free = 0;
  369. for (i = nt->sub_count; i--;) {
  370. name_sub_table *sub = nt->sub[i].names;
  371. name_string_sub_table_t *ssub = nt->sub[i].strings;
  372. if (sub != 0) {
  373. name_scan_sub(nt, i, true);
  374. if (nt->sub[i].names == 0 && gcst != 0) {
  375. /* Mark the just-freed sub-table as unmarked. */
  376. o_set_unmarked((obj_header_t *)sub - 1);
  377. o_set_unmarked((obj_header_t *)ssub - 1);
  378. }
  379. }
  380. if (i == 0)
  381. break;
  382. }
  383. nt->sub_next = 0;
  384. }
  385. /* ------ Save/restore ------ */
  386. /* Clean up the name table before a restore. */
  387. /* Currently, this is never called, because the name table is allocated */
  388. /* in system VM. However, for a Level 1 system, we might choose to */
  389. /* allocate the name table in global VM; in this case, this routine */
  390. /* would be called before doing the global part of a top-level restore. */
  391. /* Currently we don't make any attempt to optimize this. */
  392. void
  393. names_restore(name_table * nt, alloc_save_t * save)
  394. {
  395. /* We simply mark all names older than the save, */
  396. /* and let names_trace_finish sort everything out. */
  397. uint si;
  398. for (si = 0; si < nt->sub_count; ++si)
  399. if (nt->sub[si].strings != 0) {
  400. uint i;
  401. for (i = 0; i < nt_sub_size; ++i) {
  402. name_string_t *pnstr =
  403. names_index_string_inline(nt, (si << nt_log2_sub_size) + i);
  404. if (pnstr->string_bytes == 0)
  405. pnstr->mark = 0;
  406. else if (pnstr->foreign_string) {
  407. /* Avoid storing into a read-only name string. */
  408. if (!pnstr->mark)
  409. pnstr->mark = 1;
  410. } else
  411. pnstr->mark =
  412. !alloc_is_since_save(pnstr->string_bytes, save);
  413. }
  414. }
  415. names_trace_finish(nt, NULL);
  416. }
  417. /* ------ Internal procedures ------ */
  418. /* Allocate the next sub-table. */
  419. private int
  420. name_alloc_sub(name_table * nt)
  421. {
  422. gs_memory_t *mem = nt->memory;
  423. uint sub_index = nt->sub_next;
  424. name_sub_table *sub;
  425. name_string_sub_table_t *ssub;
  426. for (;; ++sub_index) {
  427. if (sub_index > nt->max_sub_count)
  428. return_error(e_limitcheck);
  429. if (nt->sub[sub_index].names == 0)
  430. break;
  431. }
  432. nt->sub_next = sub_index + 1;
  433. if (nt->sub_next > nt->sub_count)
  434. nt->sub_count = nt->sub_next;
  435. sub = gs_alloc_struct(mem, name_sub_table, &st_name_sub_table,
  436. "name_alloc_sub(sub-table)");
  437. ssub = gs_alloc_struct(mem, name_string_sub_table_t,
  438. &st_name_string_sub_table,
  439. "name_alloc_sub(string sub-table)");
  440. if (sub == 0 || ssub == 0) {
  441. gs_free_object(mem, ssub, "name_alloc_sub(string sub-table)");
  442. gs_free_object(mem, sub, "name_alloc_sub(sub-table)");
  443. return_error(e_VMerror);
  444. }
  445. memset(sub, 0, sizeof(name_sub_table));
  446. memset(ssub, 0, sizeof(name_string_sub_table_t));
  447. /* The following code is only used if EXTEND_NAMES is non-zero. */
  448. #if name_extension_bits > 0
  449. sub->high_index = (sub_index >> (16 - nt_log2_sub_size)) << 16;
  450. #endif
  451. nt->sub[sub_index].names = sub;
  452. nt->sub[sub_index].strings = ssub;
  453. /* Add the newly allocated entries to the free list. */
  454. /* Note that the free list will only be properly sorted if */
  455. /* it was empty initially. */
  456. name_scan_sub(nt, sub_index, false);
  457. #ifdef DEBUG
  458. if (gs_debug_c('n')) { /* Print the lengths of the hash chains. */
  459. int i0;
  460. for (i0 = 0; i0 < NT_HASH_SIZE; i0 += 16) {
  461. int i;
  462. dlprintf1("[n]chain %d:", i0);
  463. for (i = i0; i < i0 + 16; i++) {
  464. int n = 0;
  465. uint nidx;
  466. for (nidx = nt->hash[i]; nidx != 0;
  467. nidx = name_next_index(nidx,
  468. names_index_string_inline(nt, nidx))
  469. )
  470. n++;
  471. dprintf1(" %d", n);
  472. }
  473. dputc('\n');
  474. }
  475. }
  476. #endif
  477. return 0;
  478. }
  479. /* Free a sub-table. */
  480. private void
  481. name_free_sub(name_table * nt, uint sub_index)
  482. {
  483. gs_free_object(nt->memory, nt->sub[sub_index].strings,
  484. "name_free_sub(string sub-table)");
  485. gs_free_object(nt->memory, nt->sub[sub_index].names,
  486. "name_free_sub(sub-table)");
  487. nt->sub[sub_index].names = 0;
  488. nt->sub[sub_index].strings = 0;
  489. }
  490. /* Scan a sub-table and add unmarked entries to the free list. */
  491. /* We add the entries in decreasing count order, so the free list */
  492. /* will stay sorted. If all entries are unmarked and free_empty is true, */
  493. /* free the sub-table. */
  494. private void
  495. name_scan_sub(name_table * nt, uint sub_index, bool free_empty)
  496. {
  497. name_string_sub_table_t *ssub = nt->sub[sub_index].strings;
  498. uint free = nt->free;
  499. uint nbase = sub_index << nt_log2_sub_size;
  500. uint ncnt = nbase + (nt_sub_size - 1);
  501. bool keep = !free_empty;
  502. if (ssub == 0)
  503. return;
  504. if (nbase == 0)
  505. nbase = 1, keep = true; /* don't free name 0 */
  506. for (;; --ncnt) {
  507. uint nidx = name_count_to_index(ncnt);
  508. name_string_t *pnstr = &ssub->strings[nidx & nt_sub_index_mask];
  509. if (pnstr->mark)
  510. keep = true;
  511. else {
  512. set_name_next_index(nidx, pnstr, free);
  513. free = nidx;
  514. }
  515. if (ncnt == nbase)
  516. break;
  517. }
  518. if (keep)
  519. nt->free = free;
  520. else {
  521. /* No marked entries, free the sub-table. */
  522. name_free_sub(nt, sub_index);
  523. if (sub_index == nt->sub_count - 1) {
  524. /* Back up over a final run of deleted sub-tables. */
  525. do {
  526. --sub_index;
  527. } while (nt->sub[sub_index].names == 0);
  528. nt->sub_count = sub_index + 1;
  529. if (nt->sub_next > sub_index)
  530. nt->sub_next = sub_index;
  531. } else if (nt->sub_next == sub_index)
  532. nt->sub_next--;
  533. }
  534. }
  535. /* Garbage collector enumeration and relocation procedures. */
  536. private
  537. ENUM_PTRS_BEGIN_PROC(name_table_enum_ptrs)
  538. {
  539. EV_CONST name_table *const nt = vptr;
  540. uint i = index >> 1;
  541. if (i >= nt->sub_count)
  542. return 0;
  543. if (index & 1)
  544. ENUM_RETURN(nt->sub[i].strings);
  545. else
  546. ENUM_RETURN(nt->sub[i].names);
  547. }
  548. ENUM_PTRS_END_PROC
  549. private RELOC_PTRS_WITH(name_table_reloc_ptrs, name_table *nt)
  550. {
  551. uint sub_count = nt->sub_count;
  552. uint i;
  553. /* Now we can relocate the sub-table pointers. */
  554. for (i = 0; i < sub_count; i++) {
  555. RELOC_VAR(nt->sub[i].names);
  556. RELOC_VAR(nt->sub[i].strings);
  557. }
  558. /*
  559. * We also need to relocate the cached value pointers.
  560. * We don't do this here, but in a separate scan over the
  561. * permanent dictionaries, at the very end of garbage collection.
  562. */
  563. }
  564. RELOC_PTRS_END
  565. private ENUM_PTRS_BEGIN_PROC(name_string_sub_enum_ptrs)
  566. {
  567. return 0;
  568. }
  569. ENUM_PTRS_END_PROC
  570. private RELOC_PTRS_BEGIN(name_string_sub_reloc_ptrs)
  571. {
  572. name_string_t *pnstr = ((name_string_sub_table_t *)vptr)->strings;
  573. uint i;
  574. for (i = 0; i < nt_sub_size; ++pnstr, ++i) {
  575. if (pnstr->string_bytes != 0 && !pnstr->foreign_string) {
  576. gs_const_string nstr;
  577. nstr.data = pnstr->string_bytes;
  578. nstr.size = pnstr->string_size;
  579. RELOC_CONST_STRING_VAR(nstr);
  580. pnstr->string_bytes = nstr.data;
  581. }
  582. }
  583. }
  584. RELOC_PTRS_END