Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-b246709
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALDict.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2016 Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/*
21 * Dictionary is implemented as a hash search with algorithm adopted
22 * from "The C Programming Language" by Kernighan and Ritchie, 2nd ed.
23 * section 6.6.
24 */
25
26#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
29#include <unistd.h>
30
31#include <lal/LALStdio.h>
32#include <lal/LALStdlib.h>
33#include <lal/LALString.h>
34#include <lal/LALDict.h>
35#include "LALValue_private.h"
36#include "config.h"
37
38#define LAL_DICT_HASHSIZE 101
39
42 char *key;
43 LALValue value;
44};
45
46struct tagLALDict {
47 size_t size;
49};
50
51static size_t hash(const char *s)
52{
53 size_t hashval;
54 for (hashval = 0; *s != '\0'; ++s)
55 hashval = *s + 31 * hashval;
56 return hashval;
57}
58
59/* DICT ENTRY ROUTINES */
60
61void XLALDictEntryFree(LALDictEntry *list)
62{
63 while (list) {
64 LALDictEntry *next = list->next;
65 if (list->key)
66 LALFree(list->key);
67 LALFree(list);
68 list = next;
69 }
70 return;
71}
72
73LALDictEntry * XLALDictEntryAlloc(size_t size)
74{
75 LALDictEntry *entry;
76 entry = XLALMalloc(sizeof(*entry) + size);
77 if (!entry)
79 entry->key = NULL;
80 entry->value.size = size;
81 return entry;
82}
83
84LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size)
85{
86 if (entry == NULL)
87 return XLALDictEntryAlloc(size);
88 if (entry->value.size == size)
89 return entry;
90 entry = XLALRealloc(entry, sizeof(*entry) + size);
91 if (!entry)
93 entry->value.size = size;
94 return entry;
95}
96
97LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key)
98{
99 if (entry->key)
100 LALFree(entry->key);
101 if ((entry->key = XLALStringDuplicate(key)) == NULL)
103 return entry;
104}
105
106LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type)
107{
108 if (XLALValueSet(&entry->value, data, size, type) == NULL)
110 return entry;
111}
112
113/* warning: shallow pointer */
114const char * XLALDictEntryGetKey(const LALDictEntry *entry)
115{
116 return entry->key;
117}
118
119/* warning: shallow pointer */
120const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry)
121{
122 return &entry->value;
123}
124
125/* DICT ROUTINES */
126
127void XLALClearDict(LALDict *dict)
128{
129 if (dict) {
130 for (size_t i = 0; i < dict->size; ++i)
131 XLALDictEntryFree(dict->hashes[i]);
132 memset(dict, 0, sizeof(dict) + LAL_DICT_HASHSIZE * sizeof(*dict->hashes));
133 dict->size = LAL_DICT_HASHSIZE;
134 }
135}
136
137void XLALDestroyDict(LALDict *dict)
138{
139 if (dict) {
140 size_t i;
141 for (i = 0; i < dict->size; ++i)
142 XLALDictEntryFree(dict->hashes[i]);
143 LALFree(dict);
144 }
145 return;
146}
147
148LALDict * XLALCreateDict(void)
149{
150 LALDict *dict;
151 dict = XLALCalloc(1, sizeof(dict) + LAL_DICT_HASHSIZE * sizeof(*dict->hashes));
152 if (!dict)
154 dict->size = LAL_DICT_HASHSIZE;
155 return dict;
156}
157
158void XLALDictForeach(LALDict *dict, void (*func)(char *, LALValue *, void *), void *thunk)
159{
160 size_t i;
161 for (i = 0; i < dict->size; ++i) {
162 LALDictEntry *entry;
163 for (entry = dict->hashes[i]; entry != NULL; entry = entry->next)
164 func(entry->key, &entry->value, thunk);
165 }
166 return;
167}
168
169LALDictEntry * XLALDictFind(LALDict *dict, int (*func)(const char *, const LALValue *, void *), void *thunk)
170{
171 size_t i;
172 for (i = 0; i < dict->size; ++i) {
173 LALDictEntry *entry;
174 for (entry = dict->hashes[i]; entry != NULL; entry = entry->next)
175 if (func(entry->key, &entry->value, thunk))
176 return entry;
177 }
178 return NULL;
179}
180
181void XLALDictIterInit(LALDictIter *iter, LALDict *dict)
182{
183 iter->dict = dict;
184 iter->pos = 0;
185 iter->next = NULL;
186 return;
187}
188
189LALDictEntry * XLALDictIterNext(LALDictIter *iter)
190{
191 while (1) {
192
193 if (iter->next) {
194 LALDictEntry *entry = iter->next;
195 iter->next = entry->next;
196 return entry;
197 }
198
199 /* check end of iteration */
200 if (iter->pos >= iter->dict->size)
201 return NULL;
202
203 iter->next = iter->dict->hashes[iter->pos++];
204 }
205 return NULL;
206}
207
208int XLALDictUpdate(LALDict *dst, const LALDict *src)
209{
210 size_t i;
213 for (i = 0; i < src->size; ++i) {
214 const LALDictEntry *entry;
215 for (entry = src->hashes[i]; entry != NULL; entry = entry->next) {
216 const char *key = XLALDictEntryGetKey(entry);
217 const LALValue *value = XLALDictEntryGetValue(entry);
218 if (XLALDictInsertValue(dst, key, value) < 0)
220 }
221 }
222 return XLAL_SUCCESS;
223}
224
225LALDict * XLALDictMerge(const LALDict *dict1, const LALDict *dict2)
226{
227 LALDict *new = XLALCreateDict();
229 if (dict1)
231 if (dict2)
233 return new;
234XLAL_FAIL:
235 XLALDestroyDict(new);
236 return NULL;
237}
238
239LALDict * XLALDictDuplicate(const LALDict *orig)
240{
241 return XLALDictMerge(orig, NULL);
242}
243
244LALList * XLALDictKeys(const LALDict *dict)
245{
246 LALList *list;
247 size_t i;
248 list = XLALCreateList();
249 if (!list)
251 for (i = 0; i < dict->size; ++i) {
252 const LALDictEntry *entry;
253 for (entry = dict->hashes[i]; entry != NULL; entry = entry->next) {
254 const char *key = XLALDictEntryGetKey(entry);
255 if (XLALListAddStringValue(list, key) < 0) {
256 XLALDestroyList(list);
258 }
259 }
260 }
261 return list;
262}
263
264LALList * XLALDictValues(const LALDict *dict)
265{
266 LALList *list;
267 size_t i;
268 list = XLALCreateList();
269 if (!list)
271 for (i = 0; i < dict->size; ++i) {
272 const LALDictEntry *entry;
273 for (entry = dict->hashes[i]; entry != NULL; entry = entry->next) {
274 const LALValue *value = XLALDictEntryGetValue(entry);
275 if (XLALListAddValue(list, value) < 0) {
276 XLALDestroyList(list);
278 }
279 }
280 }
281 return list;
282}
283
284int XLALDictContains(const LALDict *dict, const char *key)
285{
286 const LALDictEntry *entry;
287 for (entry = dict->hashes[hash(key) % dict->size]; entry != NULL; entry = entry->next)
288 if (strcmp(key, entry->key) == 0)
289 return 1;
290 return 0;
291}
292
293size_t XLALDictSize(const LALDict *dict)
294{
295 size_t size = 0;
296 size_t i;
297 for (i = 0; i < dict->size; ++i) {
298 const LALDictEntry *entry;
299 for (entry = dict->hashes[i]; entry != NULL; entry = entry->next)
300 ++size;
301 }
302 return size;
303}
304
305LALDictEntry *XLALDictLookup(const LALDict *dict, const char *key)
306{
307 LALDictEntry *entry;
308 for (entry = dict->hashes[hash(key) % dict->size]; entry != NULL; entry = entry->next)
309 if (strcmp(key, entry->key) == 0)
310 return entry;
311 return NULL;
312}
313
314LALDictEntry *XLALDictPop(LALDict *dict, const char *key)
315{
316 size_t hashidx = hash(key) % dict->size;
317 LALDictEntry *this = dict->hashes[hashidx];
318 LALDictEntry *prev = this;
319 while (this) {
320 if (strcmp(this->key, key) == 0) { /* found it! */
321 if (prev == this) /* head is removed */
322 dict->hashes[hashidx] = this->next;
323 else
324 prev->next = this->next;
325 this->next = NULL;
326 return this;
327 }
328 prev = this;
329 this = this->next;
330 }
331 /* not found */
332 XLAL_ERROR_NULL(XLAL_ENAME, "Key `%s' not found", key);
333}
334
335int XLALDictRemove(LALDict *dict, const char *key)
336{
337 LALDictEntry *entry;
338 entry = XLALDictPop(dict, key);
339 XLAL_CHECK(entry, XLAL_EFUNC); /* not found */
340 XLALDictEntryFree(entry);
341 return XLAL_SUCCESS;
342}
343
344int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type)
345{
346 size_t hashidx = hash(key) % dict->size;
347 LALDictEntry *this = dict->hashes[hashidx];
348 LALDictEntry *prev = NULL;
349 LALDictEntry *entry;
350
351 /* see if entry already exists */
352 while (this) {
353 if (strcmp(this->key, key) == 0) { /* found it! */
354 entry = XLALDictEntryRealloc(this, size);
355 if (entry == NULL)
357 if (entry != this) { /* relink */
358 if (prev == NULL) /* head is moved */
359 dict->hashes[hashidx] = entry;
360 else
361 prev->next = entry;
362 }
363 entry = XLALDictEntrySetValue(entry, data, size, type);
364
365 if (entry == NULL)
367
368 return 0;
369 }
370 prev = this;
371 this = this->next;
372 }
373
374 /* not found: create new entry */
375 entry = XLALDictEntryAlloc(size);
376 if (entry == NULL)
378
379 entry = XLALDictEntrySetKey(entry, key);
380 if (entry == NULL) {
381 LALFree(entry);
383 }
384
385 entry = XLALDictEntrySetValue(entry, data, size, type);
386 if (entry == NULL) {
387 LALFree(entry);
389 }
390
391 entry->next = dict->hashes[hashidx];
392 dict->hashes[hashidx] = entry;
393 return 0;
394}
395
396int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value)
397{
399 size_t size = XLALValueGetSize(value);
400 const void * data = XLALValueGetDataPtr(value);
401 return XLALDictInsert(dict, key, data, size, type);
402}
403
404int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size)
405{
406 if (XLALDictInsert(dict, key, blob, size, LAL_UCHAR_TYPE_CODE) < 0)
408 return 0;
409}
410
411int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
412{
413 size_t size = strlen(string) + 1;
414 if (XLALDictInsert(dict, key, string, size, LAL_CHAR_TYPE_CODE) < 0)
416 return 0;
417}
418
419#define DEFINE_INSERT_FUNC(TYPE, TCODE) \
420 int XLALDictInsert ## TYPE ## Value(LALDict *dict, const char *key, TYPE value) \
421 { \
422 if (XLALDictInsert(dict, key, &value, sizeof(value), TCODE) < 0) \
423 XLAL_ERROR(XLAL_EFUNC); \
424 return 0; \
425 }
426
439
440#undef DEFINE_INSERT_FUNC
441
442void * XLALDictLookupBLOBValue(const LALDict *dict, const char *key)
443{
444 LALDictEntry *entry = XLALDictLookup(dict, key);
445 const LALValue *value;
446 if (entry == NULL)
447 XLAL_ERROR_NULL(XLAL_ENAME, "Key `%s' not found", key);
449 if (value == NULL)
451 return XLALValueGetBLOB(value);
452}
453
454/* warning: shallow pointer */
455const char * XLALDictLookupStringValue(const LALDict *dict, const char *key)
456{
457 LALDictEntry *entry = XLALDictLookup(dict, key);
458 const LALValue *value;
459 if (entry == NULL)
460 XLAL_ERROR_NULL(XLAL_ENAME, "Key `%s' not found", key);
462 if (value == NULL)
465}
466
467#define DEFINE_LOOKUP_FUNC(TYPE, FAILVAL) \
468 TYPE XLALDictLookup ## TYPE ## Value(const LALDict *dict, const char *key) \
469 { \
470 LALDictEntry *entry; \
471 const LALValue *value; \
472 entry = XLALDictLookup(dict, key); \
473 if (entry == NULL) \
474 XLAL_ERROR_VAL(FAILVAL, XLAL_ENAME, "Key `%s' not found", key); \
475 value = XLALDictEntryGetValue(entry); \
476 if (value == NULL) \
477 XLAL_ERROR_VAL(FAILVAL, XLAL_EFUNC); \
478 return XLALValueGet ## TYPE (value); \
479 }
480
493
494REAL8 XLALDictLookupValueAsREAL8(const LALDict *dict, const char *key)
495{
496 LALDictEntry *entry;
497 const LALValue *value;
498 entry = XLALDictLookup(dict, key);
499 if (entry == NULL)
500 XLAL_ERROR_REAL8(XLAL_ENAME, "Key `%s' not found", key);
502 if (value == NULL)
505}
506
507LALValue * XLALDictPopValue(LALDict *dict, const char *key)
508{
509 LALDictEntry *entry;
510 LALValue *value;
511 entry = XLALDictPop(dict, key);
514 XLALDictEntryFree(entry);
515 return value;
516}
517
518void * XLALDictPopBLOBValue(LALDict *dict, const char *key)
519{
520 LALDictEntry *entry;
521 void *value;
522 entry = XLALDictPop(dict, key);
525 XLALDictEntryFree(entry);
526 return value;
527}
528
529char * XLALDictPopStringValue(LALDict *dict, const char *key)
530{
531 LALDictEntry *entry;
532 char *value;
533 entry = XLALDictPop(dict, key);
536 XLALDictEntryFree(entry);
538 return value;
539}
540
541#define DEFINE_POP_FUNC(TYPE, FAILVAL) \
542 TYPE XLALDictPop ## TYPE ## Value(LALDict *dict, const char *key) \
543 { \
544 LALDictEntry *entry; \
545 TYPE value; \
546 entry = XLALDictPop(dict, key); \
547 XLAL_CHECK_VAL(FAILVAL, entry, XLAL_EFUNC); \
548 value = XLALValueGet ## TYPE(XLALDictEntryGetValue(entry)); \
549 XLALDictEntryFree(entry); \
550 return value; \
551 }
552
565
566REAL8 XLALDictPopValueAsREAL8(LALDict *dict, const char *key)
567{
568 LALDictEntry *entry;
569 REAL8 value;
570 entry = XLALDictPop(dict, key);
573 XLALDictEntryFree(entry);
574 return value;
575}
576
578
579static void XLALDictAsStringAppendValueFunc(char *key, LALValue *value, void *thunk)
580{
582 if (p->first)
583 p->first = 0;
584 else
585 p->s = XLALStringAppend(p->s, ", ");
586 p->s = XLALStringAppendFmt(p->s, "\"%s\": ", key);
587 p->s = XLALValueAsStringAppend(p->s, value);
588 return;
589}
590
591char * XLALDictAsStringAppend(char *s, const LALDict *dict)
592{
593 LALDict *d = (LALDict *)(uintptr_t)dict; // discarding const qual is harmless
595 p.s = XLALStringAppend(p.s, "{");
597 p.s = XLALStringAppend(p.s, "}");
598 return p.s;
599}
600
601void XLALDictPrint(const LALDict *dict, int fd)
602{
603 char *s = NULL;
604 s = XLALDictAsStringAppend(s, dict);
606#if HAVE_DPRINTF
607 dprintf(fd, "%s", s);
608#else
609 /* hack... */
610 switch (fd) {
611 case 1:
612 fprintf(stdout, "%s", s);
613 break;
614 case 2:
615 fprintf(stderr, "%s", s);
616 break;
617 default:
618 LALFree(s);
619 XLAL_ERROR_VOID(XLAL_EIO, "Don't know what to do with file descriptor %d", fd);
620 }
621#endif
622 LALFree(s);
623 return;
624}
int XLALDictContains(const LALDict *dict, const char *key)
Definition: LALDict.c:284
LALDictEntry * XLALDictIterNext(LALDictIter *iter)
Definition: LALDict.c:189
void * XLALDictPopBLOBValue(LALDict *dict, const char *key)
Definition: LALDict.c:518
LALValue * XLALDictPopValue(LALDict *dict, const char *key)
Definition: LALDict.c:507
REAL8 XLALDictLookupValueAsREAL8(const LALDict *dict, const char *key)
Definition: LALDict.c:494
LALList * XLALDictKeys(const LALDict *dict)
Definition: LALDict.c:244
int XLALDictUpdate(LALDict *dst, const LALDict *src)
Definition: LALDict.c:208
static void XLALDictAsStringAppendValueFunc(char *key, LALValue *value, void *thunk)
Definition: LALDict.c:579
LALDictEntry * XLALDictEntrySetValue(LALDictEntry *entry, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:106
LALDictEntry * XLALDictPop(LALDict *dict, const char *key)
Definition: LALDict.c:314
LALDictEntry * XLALDictEntryAlloc(size_t size)
Definition: LALDict.c:73
int XLALDictInsert(LALDict *dict, const char *key, const void *data, size_t size, LALTYPECODE type)
Definition: LALDict.c:344
#define DEFINE_INSERT_FUNC(TYPE, TCODE)
Definition: LALDict.c:419
LALDictEntry * XLALDictLookup(const LALDict *dict, const char *key)
Definition: LALDict.c:305
char * XLALDictPopStringValue(LALDict *dict, const char *key)
Definition: LALDict.c:529
LALDict * XLALDictMerge(const LALDict *dict1, const LALDict *dict2)
Definition: LALDict.c:225
void * XLALDictLookupBLOBValue(const LALDict *dict, const char *key)
Definition: LALDict.c:442
const char * XLALDictLookupStringValue(const LALDict *dict, const char *key)
Definition: LALDict.c:455
void XLALDictEntryFree(LALDictEntry *list)
Definition: LALDict.c:61
int XLALDictRemove(LALDict *dict, const char *key)
Definition: LALDict.c:335
#define DEFINE_LOOKUP_FUNC(TYPE, FAILVAL)
Definition: LALDict.c:467
void XLALDestroyDict(LALDict *dict)
Definition: LALDict.c:137
LALDict * XLALDictDuplicate(const LALDict *orig)
Definition: LALDict.c:239
LALDict * XLALCreateDict(void)
Definition: LALDict.c:148
LALList * XLALDictValues(const LALDict *dict)
Definition: LALDict.c:264
void XLALClearDict(LALDict *dict)
Definition: LALDict.c:127
LALDictEntry * XLALDictEntrySetKey(LALDictEntry *entry, const char *key)
Definition: LALDict.c:97
int XLALDictInsertBLOBValue(LALDict *dict, const char *key, const void *blob, size_t size)
Definition: LALDict.c:404
#define DEFINE_POP_FUNC(TYPE, FAILVAL)
Definition: LALDict.c:541
size_t XLALDictSize(const LALDict *dict)
Definition: LALDict.c:293
void XLALDictIterInit(LALDictIter *iter, LALDict *dict)
Definition: LALDict.c:181
#define LAL_DICT_HASHSIZE
Definition: LALDict.c:38
void XLALDictPrint(const LALDict *dict, int fd)
Definition: LALDict.c:601
int XLALDictInsertValue(LALDict *dict, const char *key, const LALValue *value)
Definition: LALDict.c:396
static size_t hash(const char *s)
Definition: LALDict.c:51
char * XLALDictAsStringAppend(char *s, const LALDict *dict)
Definition: LALDict.c:591
const char * XLALDictEntryGetKey(const LALDictEntry *entry)
Definition: LALDict.c:114
int XLALDictInsertStringValue(LALDict *dict, const char *key, const char *string)
Definition: LALDict.c:411
const LALValue * XLALDictEntryGetValue(const LALDictEntry *entry)
Definition: LALDict.c:120
LALDictEntry * XLALDictFind(LALDict *dict, int(*func)(const char *, const LALValue *, void *), void *thunk)
Definition: LALDict.c:169
void XLALDictForeach(LALDict *dict, void(*func)(char *, LALValue *, void *), void *thunk)
Definition: LALDict.c:158
LALDictEntry * XLALDictEntryRealloc(LALDictEntry *entry, size_t size)
Definition: LALDict.c:84
REAL8 XLALDictPopValueAsREAL8(LALDict *dict, const char *key)
Definition: LALDict.c:566
int XLALListAddValue(LALList *list, const LALValue *value)
Definition: LALList.c:509
LALList * XLALCreateList(void)
Definition: LALList.c:169
int XLALListAddStringValue(LALList *list, const char *string)
Definition: LALList.c:522
void XLALDestroyList(LALList *list)
Definition: LALList.c:155
#define LALFree(p)
Definition: LALMalloc.h:96
char * XLALStringAppendFmt(char *s, const char *fmt,...)
Append the formatted string 'fmt' to the string 's', which is reallocated with XLALRealloc() to the r...
Definition: LALString.c:69
char * XLALValueAsStringAppend(char *s, const LALValue *value)
Definition: LALValue.c:313
const void * XLALValueGetDataPtr(const LALValue *value)
Definition: LALValue.c:191
REAL8 XLALValueGetAsREAL8(const LALValue *value)
Definition: LALValue.c:256
LALValue * XLALValueSet(LALValue *value, const void *data, size_t size, LALTYPECODE type)
Definition: LALValue.c:68
LALValue * XLALValueDuplicate(const LALValue *value)
Definition: LALValue.c:51
const char * XLALValueGetString(const LALValue *value)
Definition: LALValue.c:223
size_t XLALValueGetSize(const LALValue *value)
Definition: LALValue.c:185
void * XLALValueGetBLOB(const LALValue *value)
Definition: LALValue.c:210
LALTYPECODE XLALValueGetType(const LALValue *value)
Definition: LALValue.c:180
#define fprintf
LALTYPECODE
Type codes: use these type codes to identify a LAL atomic data type, see Headers LAL(Atomic)Datatypes...
Definition: LALDatatypes.h:49
unsigned char UCHAR
One-byte unsigned integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint64_t UINT8
Eight-byte unsigned integer; on some platforms this is equivalent to unsigned long int instead.
double complex COMPLEX16
Double-precision floating-point complex number (16 bytes total)
double REAL8
Double precision real floating-point number (8 bytes).
int16_t INT2
Two-byte signed integer.
int64_t INT8
Eight-byte signed integer; on some platforms this is equivalent to long int instead.
uint16_t UINT2
Two-byte unsigned integer.
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
float complex COMPLEX8
Single-precision floating-point complex number (8 bytes total)
int32_t INT4
Four-byte signed integer.
float REAL4
Single precision real floating-point number (4 bytes).
@ LAL_C_TYPE_CODE
COMPLEX8 type code (27)
Definition: LALDatatypes.h:60
@ LAL_CHAR_TYPE_CODE
CHAR type code (0)
Definition: LALDatatypes.h:50
@ LAL_U2_TYPE_CODE
UINT2 type code (33)
Definition: LALDatatypes.h:55
@ LAL_Z_TYPE_CODE
COMPLEX16 type code (28)
Definition: LALDatatypes.h:61
@ LAL_S_TYPE_CODE
REAL4 type code (18)
Definition: LALDatatypes.h:58
@ LAL_I2_TYPE_CODE
INT2 type code (1)
Definition: LALDatatypes.h:51
@ LAL_I8_TYPE_CODE
INT8 type code (3)
Definition: LALDatatypes.h:53
@ LAL_D_TYPE_CODE
REAL8 type code (19)
Definition: LALDatatypes.h:59
@ LAL_I4_TYPE_CODE
INT4 type code (2)
Definition: LALDatatypes.h:52
@ LAL_UCHAR_TYPE_CODE
UCHAR type code (32)
Definition: LALDatatypes.h:54
@ LAL_U8_TYPE_CODE
UINT8 type code (35)
Definition: LALDatatypes.h:57
@ LAL_U4_TYPE_CODE
UINT4 type code (34)
Definition: LALDatatypes.h:56
#define XLALMalloc(n)
Definition: LALMalloc.h:44
#define XLALCalloc(m, n)
Definition: LALMalloc.h:45
#define XLALRealloc(p, n)
Definition: LALMalloc.h:46
char * XLALStringDuplicate(const char *s)
Like strdup but uses LAL allocation routines (free with LALFree).
Definition: LALString.c:89
char * XLALStringAppend(char *s, const char *append)
Like strcat but dynamically reallocates string with LALRealloc.
Definition: LALString.c:50
#define XLAL_ERROR_VOID(...)
Macro to invoke a failure from a XLAL routine returning void.
Definition: XLALError.h:726
#define XLAL_ERROR_REAL8(...)
Macro to invoke a failure from a XLAL routine returning a REAL8.
Definition: XLALError.h:752
#define XLAL_ERROR_NULL(...)
Macro to invoke a failure from a XLAL routine returning a pointer.
Definition: XLALError.h:713
#define XLAL_ERROR(...)
Macro to invoke a failure from a XLAL routine returning an integer.
Definition: XLALError.h:700
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
Definition: XLALError.h:810
#define XLAL_CHECK_VOID(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns void.
Definition: XLALError.h:840
#define XLAL_REAL4_FAIL_NAN
Floating-point value of the XLAL REAL4 failure NaN.
Definition: XLALError.h:388
#define XLAL_REAL8_FAIL_NAN
Floating-point value of the XLAL REAL8 failure NaN.
Definition: XLALError.h:389
#define XLAL_CHECK_FAIL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true by jumping to a XLAL_FAIL label.
Definition: XLALError.h:900
#define XLAL_CHECK_REAL8(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a REAL8.
Definition: XLALError.h:870
#define XLAL_CHECK_NULL(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a pointe...
Definition: XLALError.h:825
@ XLAL_ENOMEM
Memory allocation error.
Definition: XLALError.h:407
@ XLAL_SUCCESS
Success return value (not an error number)
Definition: XLALError.h:401
@ XLAL_EFAULT
Invalid pointer.
Definition: XLALError.h:408
@ XLAL_ENAME
Wrong name.
Definition: XLALError.h:426
@ XLAL_EFUNC
Internal function call failed bit: "or" this with existing error number.
Definition: XLALError.h:462
@ XLAL_EIO
I/O error.
Definition: XLALError.h:406
@ XLAL_FAILURE
Failure return value (not an error number)
Definition: XLALError.h:402
Definition: LALDict.c:40
struct tagLALDictEntry * next
Definition: LALDict.c:41
char * key
Definition: LALDict.c:42
LALValue value
Definition: LALDict.c:43
struct tagLALDictEntry * hashes[]
Definition: LALDict.c:48
size_t size
Definition: LALDict.c:47