1 /********************************************************************
3 * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
4 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
5 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
6 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
9 * by the XIPHOPHORUS Company http://www.xiph.org/ *
11 ********************************************************************
13 function: Creates an image of strutures and mappings in registry.c
14 to be copied into shared memory segment via DllMain().
17 created: 06-Sep-2001, Chris Wolf
19 last mod: $Id: shmmap_c.h,v 1.1 2001/09/11 20:16:11 cwolf Exp $
21 This module gets conditionally appended to the end of registry.c
22 ********************************************************************/
29 * Create image of mappings defined in regsitry.c.
31 * PARAM len: pointer to callers length indicator, will indicate
33 * RETURN SHARED_MAP: pointer to allocated mapping image, NULL on failure.
35 SHARED_MAP* table_map2mem(int *len)
41 if ((map = calloc(1, sizeof(SHARED_MAP))) == (SHARED_MAP*)0)
42 return (SHARED_MAP*)0;
44 size = sizeof(SHARED_MAP);
46 if ((map->p_time_P = calloc(NUMELEMENTS(_time_P),
47 sizeof(vorbis_func_time*))) == (vorbis_func_time**)0)
48 return (SHARED_MAP*)0;
50 size += sizeof(_time_P);
52 for (p=0; p<NUMELEMENTS(_time_P); p++)
54 if ((map->p_time_P[p] = calloc(NUMELEMENTS(_time_P),
55 sizeof(vorbis_func_time))) == (vorbis_func_time*)0)
56 return (SHARED_MAP*)0;
58 (void)memcpy((void *)map->p_time_P[p],
59 (const void *)_time_P[p],
60 sizeof(vorbis_func_time));
62 size += sizeof(vorbis_func_time);
65 if ((map->p_floor_P = calloc(NUMELEMENTS(_floor_P),
66 sizeof(vorbis_func_floor*))) == (vorbis_func_floor**)0)
67 return (SHARED_MAP*)0;
69 size += sizeof(_floor_P);
71 for (p=0; p<NUMELEMENTS(_floor_P); p++)
73 if ((map->p_floor_P[p] = calloc(1,
74 sizeof(vorbis_func_floor))) == (vorbis_func_floor*)0)
75 return (SHARED_MAP*)0;
77 (void)memcpy((void *)map->p_floor_P[p],
78 (const void *)_floor_P[p],
79 sizeof(vorbis_func_floor));
81 size += sizeof(vorbis_func_floor);
84 if ((map->p_residue_P = calloc(NUMELEMENTS(_residue_P),
85 sizeof(vorbis_func_residue*))) == (vorbis_func_residue**)0)
86 size += sizeof(_residue_P);
88 for (p=0; p<NUMELEMENTS(_residue_P); p++)
90 if ((map->p_residue_P[p] = calloc(1,
91 sizeof(vorbis_func_residue))) == (vorbis_func_residue*)0)
92 return (SHARED_MAP*)0;
94 (void)memcpy((void *)map->p_residue_P[p],
95 (const void *)_residue_P[p],
96 sizeof(vorbis_func_residue));
98 size += sizeof(vorbis_func_residue);
101 if ((map->p_mapping_P = calloc(NUMELEMENTS(_mapping_P),
102 sizeof(vorbis_func_mapping*))) == (vorbis_func_mapping**)0)
103 return (SHARED_MAP*)0;
105 size += sizeof(_mapping_P);
107 for (p=0; p<NUMELEMENTS(_mapping_P); p++)
109 if ((map->p_mapping_P[p] = calloc(1,
110 sizeof(vorbis_func_mapping))) == (vorbis_func_mapping*)0)
111 return (SHARED_MAP*)0;
113 (void)memcpy((void *)map->p_mapping_P[p],
114 (const void *)_mapping_P[p],
115 sizeof(vorbis_func_mapping));
117 size += sizeof(vorbis_func_mapping);