Chameleon

Chameleon Commit Details

Date:2013-01-10 16:43:45 (7 years 4 months ago)
Author:armel cadet-petit
Commit:2156
Parents: 2155
Message:updated platform.c and modules.c
Changes:
M/branches/cparm/i386/libsaio/modules.h
M/branches/cparm/i386/libsaio/platform.c
M/branches/cparm/i386/libsaio/modules.c
M/branches/cparm/CHANGES

File differences

branches/cparm/CHANGES
1
2
3
14
25
36
- Updated platform.c
- Updated modules.c
- Updated cpu.c
- Added a C exeption handler
- Added libz
branches/cparm/i386/libsaio/modules.c
1313
1414
1515
16
17
18
1619
1720
1821
......
2326
2427
2528
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
2646
2747
2848
......
3151
3252
3353
34
54
55
3556
57
58
59
60
61
62
3663
3764
3865
......
154181
155182
156183
157
184
158185
159186
160187
......
217244
218245
219246
220
247
221248
222249
223250
......
243270
244271
245272
246
273
247274
248275
249276
......
283310
284311
285312
286
313
287314
288315
289316
......
440467
441468
442469
443
470
444471
445
472
446473
447474
448475
......
659686
660687
661688
662
689
663690
664691
665692
666693
667694
668
695
669696
670697
671698
672699
673700
674701
675
702
676703
677704
678705
......
861888
862889
863890
891
892
893
894
895
864896
865897
866898
......
942974
943975
944976
977
978
945979
946
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
9471003
948
1004
9491005
9501006
9511007
......
14881544
14891545
14901546
1491
1492
14931547
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
15101548
15111549
15121550
......
15251563
15261564
15271565
1528
1529
1566
1567
15301568
15311569
15321570
15331571
15341572
15351573
1536
1537
1574
1575
15381576
15391577
15401578
15411579
15421580
1543
1581
15441582
15451583
15461584
......
15591597
15601598
15611599
1562
1600
15631601
15641602
15651603
15661604
15671605
1568
1606
15691607
15701608
15711609
......
15871625
15881626
15891627
1590
1591
1592
1628
1629
1630
15931631
15941632
15951633
......
16541692
16551693
16561694
1657
1695
16581696
1659
1697
16601698
16611699
16621700
1663
1701
16641702
1665
1703
16661704
16671705
16681706
......
16841722
16851723
16861724
1687
1725
16881726
16891727
16901728
......
17741812
17751813
17761814
1777
1815
17781816
17791817
17801818
......
17861824
17871825
17881826
1789
1827
17901828
17911829
17921830
......
18051843
18061844
18071845
1808
1846
18091847
18101848
18111849
......
18141852
18151853
18161854
1817
1855
18181856
18191857
18201858
......
18401878
18411879
18421880
1843
1881
18441882
18451883
18461884
1847
1885
18481886
18491887
18501888
18511889
18521890
1853
1891
18541892
18551893
18561894
......
18591897
18601898
18611899
1862
1900
18631901
18641902
18651903
......
18801918
18811919
18821920
1883
1921
18841922
18851923
18861924
18871925
1888
1926
18891927
18901928
18911929
18921930
18931931
1894
1932
18951933
18961934
1897
1935
18981936
18991937
19001938
......
19061944
19071945
19081946
1909
1947
19101948
19111949
19121950
......
19361974
19371975
19381976
1939
1977
19401978
19411979
19421980
......
19441982
19451983
19461984
1947
1985
19481986
19491987
1950
1988
19511989
19521990
19531991
19541992
19551993
1956
1994
19571995
19581996
19591997
......
19611999
19622000
19632001
1964
2002
19652003
19662004
19672005
......
19722010
19732011
19742012
1975
2013
19762014
19772015
1978
2016
19792017
19802018
19812019
1982
2020
19832021
19842022
19852023
19862024
19872025
1988
2026
19892027
19902028
19912029
......
19972035
19982036
19992037
2000
2038
20012039
20022040
20032041
......
20162054
20172055
20182056
2019
2057
20202058
20212059
20222060
......
20352073
20362074
20372075
2038
2076
20392077
20402078
20412079
......
20522090
20532091
20542092
2055
2093
20562094
20572095
20582096
2059
2097
20602098
20612099
20622100
......
20842122
20852123
20862124
2087
2088
2125
2126
20892127
20902128
20912129
20922130
2093
2131
20942132
20952133
20962134
......
20982136
20992137
21002138
2101
2139
21022140
21032141
21042142
......
21072145
21082146
21092147
2110
2148
21112149
21122150
21132151
21142152
2115
2153
21162154
21172155
21182156
......
21232161
21242162
21252163
2126
2164
21272165
21282166
21292167
21302168
21312169
21322170
2133
2171
21342172
21352173
21362174
......
21672205
21682206
21692207
2170
2208
21712209
2172
2210
21732211
21742212
21752213
#include "bootstruct.h"
#include "modules.h"
#include "sl.h"
#include "xml.h"
#ifndef DEBUG_MODULES
#define DEBUG_MODULES 0
#endif
#define DBG(x...)
#endif
struct Bundle {
struct Bundle *nextBundle;
long willLoad;
TagPtr dict;
TagPtr personalities;
#if 0
config_file_t *LanguageConfig; // we will use an xml file instead of pure txt file ... it's easier to parse
#endif
//pool_t workspace;
char *plistAddr;
long plistLength;
char *executablePath;
char *bundlePath;
long bundlePathLength;
};
typedef struct Bundle Bundle, *BundlePtr;
// NOTE: Global so that modules can link with this
unsigned long long textAddress = 0;
unsigned long long textSection = 0;
symbolList_t* moduleSymbols = NULL;
unsigned int (*lookup_symbol)(const char*, int(*strcmp_callback)(const char*, const char*)) = NULL;
moduleHook_t* get_callback(const char* name);
static unsigned int load_module(char * name, char* module);
static unsigned int load_module(char * name, char* module, BundlePtr bundle);
static EFI_STATUS _bind_macho(char* module, void* base, char* bind_stream, UInt32 size, BundlePtr bundle);
#if macho_64
static unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char), BundlePtr bundle);
#else
static unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long), BundlePtr bundle);
#endif
#if DEBUG_MODULES
VOID print_symbol_list(VOID);
VOID print_hook_list(VOID);
return;
}
msglog("* Attempting to load module: %s\n", tmp);
module_start = (void*)load_module(dylib_name,tmp);
module_start = (void*)load_module(dylib_name,tmp, NULL);
if(module_start && ( module_start != (void*)0xFFFFFFFF))
{
continue;
}
msglog("* Attempting to load module: %s\n", tmp);
module_start = (void*)load_module(dylib_name,tmp);
module_start = (void*)load_module(dylib_name,tmp, NULL);
if(module_start && ( module_start != (void*)0xFFFFFFFF))
{
/*
* Load a module file
*/
static unsigned int load_module(char * name, char* module)
static unsigned int load_module(char * name, char* module, BundlePtr bundle)
{
unsigned int module_start = 0xFFFFFFFF;
DBG("Module %s read in.\n", module);
// Module loaded into memory, parse it
module_start = parse_mach(name, module_base, &add_symbol);
module_start = parse_mach(name, module_base, &add_symbol, bundle);
}
* happen as all dependencies are verified before the sybols are read in.
*/
#if macho_64
unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char))// TODO: add param to specify valid archs
static unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char), BundlePtr bundle)// TODO: add param to specify valid archs
#else
unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long))// TODO: add param to specify valid archs
static unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long), BundlePtr bundle)// TODO: add param to specify valid archs
#endif
{
#if macho_64
if(dyldInfoCommand && dyldInfoCommand->bind_off)
{
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size);
bind_status = _bind_macho(module, binary, (char*)dyldInfoCommand->bind_off, dyldInfoCommand->bind_size, bundle);
}
if(dyldInfoCommand && dyldInfoCommand->weak_bind_off && (bind_status == EFI_SUCCESS))
{
// NOTE: this currently should never happen.
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size);
bind_status = _bind_macho(module, binary, (char*)dyldInfoCommand->weak_bind_off, dyldInfoCommand->weak_bind_size, bundle);
}
if(dyldInfoCommand && dyldInfoCommand->lazy_bind_off && (bind_status == EFI_SUCCESS))
{
// NOTE: we are binding the lazy pointers as a module is laoded,
// This should be changed to bind when a symbol is referened at runtime instead.
bind_status = bind_macho(module, binary, (char*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size);
bind_status = _bind_macho(module, binary, (char*)dyldInfoCommand->lazy_bind_off, dyldInfoCommand->lazy_bind_size, bundle);
}
if (bind_status != EFI_SUCCESS) {
// There is apossibility that this could cause issues,
// however the macho file is 32 bit, so it shouldn't matter too much
EFI_STATUS bind_macho(char* module, void* base, char* bind_stream, UInt32 size)
{
return _bind_macho( module, base, bind_stream, size, NULL);
}
static EFI_STATUS _bind_macho(char* module, void* base, char* bind_stream, UInt32 size, BundlePtr bundle)
{
bind_stream += (UInt32)base;
UInt8 symbolFlags = immediate;
DBG("BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM: %s, 0x%X\n", symbolName, symbolFlags);
#endif
symbolAddr = 0xFFFFFFFF;
TagPtr prop;
symbolAddr = lookup_all_symbols("EXTERNAL" ,symbolName); /* Dirty hack, this will be replaced soon by a better mechanism */
if (bundle != NULL)
{
prop = XMLGetProperty(bundle->dict, kPropOSBundleLibraries);
if (prop != 0)
{
prop = prop->tag;
while (prop != 0)
{
/* the order in OSBundleLibraries is important */
if (prop->string)
{
symbolAddr = lookup_all_symbols(prop->string ,symbolName);
if (symbolAddr != 0xFFFFFFFF) break; // the symbol is found , we can exit the loop
}
prop = prop->tagNext;
}
}
}
if (symbolAddr == 0xFFFFFFFF) symbolAddr = lookup_all_symbols(NULL ,symbolName);
if (symbolAddr == 0xFFFFFFFF) symbolAddr = lookup_all_symbols(NULL ,symbolName); // at this point if the symbol is still undefined, we search everywhere by starting to the internal symbols
if((symbolAddr == 0xFFFFFFFF) && (strncmp(symbolName, SYMBOL_DYLD_STUB_BINDER,sizeof(SYMBOL_DYLD_STUB_BINDER)) != 0))
{
#include <libkern/OSByteOrder.h>
#include <mach/machine.h>
#include "sl.h"
#include "xml.h"
struct Module {
struct Module *nextModule;
long willLoad;
TagPtr dict;
TagPtr personalities;
#if 0
config_file_t *LanguageConfig; // we will use an xml file instead of pure txt file ... it's easier to parse
#endif
//pool_t workspace;
char *plistAddr;
long plistLength;
char *executablePath;
char *bundlePath;
long bundlePathLength;
};
typedef struct Module Module, *ModulePtr;
enum {
};
static ModulePtr gModuleHead;
static char * gModulesSpec;
static BundlePtr gBundleHead;
static char * gBundlesSpec;
static char * gDriverSpec;
static char * gFileSpec;
static char * gTempSpec;
static char * gFileName;
static int gLowestLoadPriority;
static long ParseXML(char *buffer, ModulePtr *module);
static ModulePtr FindBundle( char * bundle_id );
static long ParseXML(char *buffer, BundlePtr *module);
static BundlePtr FindBundle( char * bundle_id );
static void
FreeBundleSupport( void )
{
if ( gModulesSpec ) free(gModulesSpec);
if ( gBundlesSpec ) free(gBundlesSpec);
if ( gDriverSpec) free(gDriverSpec);
if ( gFileSpec ) free(gFileSpec);
if ( gTempSpec ) free(gTempSpec);
if (BundleSet == true) return 0;
gModulesSpec = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
gBundlesSpec = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
gDriverSpec = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
gFileSpec = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
gTempSpec = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
gFileName = malloc( DEFAULT_BUNDLE_SPEC_SIZE );
if ( !gModulesSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
if ( !gBundlesSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
goto error;
BundleSet = true;
return 1;
strlcpy(gModulesSpec, dirSpec, DEFAULT_BUNDLE_SPEC_SIZE);
strlcat(gModulesSpec, "Modules", DEFAULT_BUNDLE_SPEC_SIZE);
FileLoadBundles(gModulesSpec, 0);
strlcpy(gBundlesSpec, dirSpec, DEFAULT_BUNDLE_SPEC_SIZE);
strlcat(gBundlesSpec, "Modules", DEFAULT_BUNDLE_SPEC_SIZE);
FileLoadBundles(gBundlesSpec, 0);
MatchBundlesLibraries();
}
static void add_bundle(ModulePtr module,char* name)
static void add_bundle(BundlePtr module,char* name)
{
ModulePtr new_entry= malloc(sizeof(Module));
BundlePtr new_entry= malloc(sizeof(Bundle));
DBG("Adding bundle %s \n", name );
if (new_entry)
{
new_entry->nextModule = gModuleHead;
new_entry->nextBundle = gBundleHead;
gModuleHead = new_entry;
gBundleHead = new_entry;
new_entry->executablePath = module->executablePath;
new_entry->bundlePath = module->bundlePath;
LoadBundlePList( char * dirSpec, char * name, long bundleType )
{
long length, executablePathLength, bundlePathLength;
ModulePtr module = 0;
BundlePtr module = 0;
char * buffer = 0;
char * tmpExecutablePath = 0;
char * tmpBundlePath = 0;
}
#define WillLoadBundles \
module = gModuleHead; \
module = gBundleHead; \
while (module != NULL) \
{ \
if (module->willLoad == willLoad) \
fileName = prop->string; \
snprintf(gFileSpec, DEFAULT_BUNDLE_SPEC_SIZE,"%s%s", module->executablePath, fileName); \
\
module_start = (void*)load_module((char*)fileName,gFileSpec); \
module_start = (void*)load_module((char*)fileName,gFileSpec,module); \
if(!module_start || (*module_start == (void*)0xFFFFFFFF)) \
{ \
if (module->willLoad > BundlePrioritySystemLib) \
} \
} \
} \
module = module->nextModule; \
module = module->nextBundle; \
}
//==========================================================================
long LoadMatchedBundles( void )
{
TagPtr prop;
ModulePtr module;
BundlePtr module;
char *fileName;
void (*module_start)(void);
long willLoad;
{
TagPtr prop, prop2;
ModulePtr module, module2,dummy_module;
BundlePtr module, module2,dummy_module;
// Check for active modules with the same Bundle IDs or same principal class, only one must remain (except for type 3 aka system libs)
{
module = gModuleHead;
module = gBundleHead;
while (module != 0)
{
if (!(module->willLoad > BundlePriorityInit)) // if the module load priority is not higher than initialized, continue
{
module = module->nextModule;
module = module->nextBundle;
continue;
}
if (prop != 0 && prop2 != 0)
{
module2 = gModuleHead;
module2 = gBundleHead;
TagPtr prop3,prop4;
}
}
module2 = module2->nextModule;
module2 = module2->nextBundle;
}
}
module = module->nextModule;
module = module->nextBundle;
}
}
// Check for dependencies (it works in most cases, still a little buggy but should be sufficient for what we have to do,
// clearly the Achilles' heel of this implementation, please use dependencies with caution !!!)
dummy_module = gModuleHead;
dummy_module = gBundleHead;
while (dummy_module != 0)
{
module = gModuleHead;
module = gBundleHead;
while (module != 0)
{
prop = prop->tag;
while (prop != 0)
{
module2 = gModuleHead;
module2 = gBundleHead;
while (module2 != 0)
{
prop2 = XMLGetProperty(module2->dict, kPropCFBundleIdentifier);
}
if (module->willLoad != BundlePriorityNull) module->willLoad = BundlePriorityNull;
module2 = module2->nextModule;
module2 = module2->nextBundle;
}
if (module->willLoad == BundlePriorityNull) goto nextmodule;
prop = prop->tagNext;
}
}
nextmodule:
module = module->nextModule;
module = module->nextBundle;
}
dummy_module = dummy_module->nextModule;
dummy_module = dummy_module->nextBundle;
}
// Get the lowest load priority
{
gLowestLoadPriority = BundlePriorityNormalPriority;
module = gModuleHead;
module = gBundleHead;
while (module != 0)
{
{
gLowestLoadPriority = MIN(MAX(module->willLoad,gLowestLoadPriority), BundlePriorityLowestPriority);
}
module = module->nextModule;
module = module->nextBundle;
}
}
//==========================================================================
// FindBundle
static ModulePtr
static BundlePtr
FindBundle( char * bundle_id )
{
ModulePtr module;
BundlePtr module;
TagPtr prop;
DBG("FindBundle %s\n",bundle_id);
module = gModuleHead;
module = gBundleHead;
while (module != 0)
{
prop = XMLGetProperty(module->dict, kPropCFBundleIdentifier);
if ((prop != 0) && !strcmp(bundle_id, prop->string)) break;
module = module->nextModule;
module = module->nextBundle;
}
return module;
void *
GetBundleDict( char * bundle_id )
{
ModulePtr module;
BundlePtr module;
DBG("GetBundleDict %s\n",bundle_id);
module = FindBundle( bundle_id );
void *
GetBundlePersonality( char * bundle_id )
{
ModulePtr module;
BundlePtr module;
DBG("GetBundlePersonalities %s\n",bundle_id);
module = FindBundle( bundle_id );
char *
GetBundlePath( char * bundle_id )
{
ModulePtr module;
BundlePtr module;
DBG("GetBundlePath %s\n",bundle_id);
module = FindBundle( bundle_id );
// ParseXML
static long
ParseXML( char * buffer, ModulePtr * module )
ParseXML( char * buffer, BundlePtr * module )
{
long length, pos;
TagPtr moduleDict, prop;
ModulePtr tmpModule;
BundlePtr tmpBundle;
pos = 0;
DBG("ParseXML\n");
}
tmpModule = malloc(sizeof(Module));
if (tmpModule == 0)
tmpBundle = malloc(sizeof(Bundle));
if (tmpBundle == 0)
{
XMLFreeTag(moduleDict);
return -1;
}
tmpModule->dict = moduleDict;
tmpBundle->dict = moduleDict;
do {
prop = XMLGetProperty(moduleDict, kPropOSBundleEnabled);
{
if ( (strlen(prop->string) >= 1) && (prop->string[0] == 'N' || prop->string[0] == 'n') )
{
tmpModule->willLoad = 0;
tmpBundle->willLoad = 0;
break;
}
}
{
if (!strncmp(prop->string,SYSLIB_CLASS, sizeof(SYSLIB_CLASS)))
{
tmpModule->willLoad = BundlePrioritySystemLib;
tmpBundle->willLoad = BundlePrioritySystemLib;
break;
}
if (!strncmp(prop->string,SYS_CLASS, sizeof(SYS_CLASS)))
{
tmpModule->willLoad = BundlePrioritySystem;
tmpBundle->willLoad = BundlePrioritySystem;
break;
}
}
int tmpwillLoad;
if ((tmpwillLoad = strtoul(prop->string, NULL, 10)) > BundlePrioritySystemLib )
{
tmpModule->willLoad = MIN(tmpwillLoad, BundlePriorityLowestPriority);
tmpBundle->willLoad = MIN(tmpwillLoad, BundlePriorityLowestPriority);
break;
}
}
tmpModule->willLoad = BundlePriorityNormalPriority;
tmpBundle->willLoad = BundlePriorityNormalPriority;
#if 0
prop = XMLGetProperty(moduleDict, kPropCFBundleLocalizations);
} while (0);
// Get the personalities.
tmpModule->personalities = XMLGetProperty(moduleDict, kPropIOKitPersonalities);
tmpBundle->personalities = XMLGetProperty(moduleDict, kPropIOKitPersonalities);
*module = tmpModule;
*module = tmpBundle;
branches/cparm/i386/libsaio/modules.h
8888
8989
9090
91
92
93
94
95
96
9791
9892
9993
#endif
#if macho_64
unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long, char));
#else
unsigned int parse_mach(char *module, void* binary, long long(*symbol_handler)(char*, char*, long long));
#endif
#if macho_64
unsigned int handle_symtable(char *module, UInt32 base,
struct symtab_command* symtabCommand,
long long(*symbol_handler)(char*, char*, long long, char),
branches/cparm/i386/libsaio/platform.c
9898
9999
100100
101
102
103
101
102
103
104
105
106
107
108
109
104110
105111
106112
107113
108
109
110
111114
112115
113116
......
153156
154157
155158
156
159
160
161
162
163
157164
158165
159166
......
163170
164171
165172
166
173
174
167175
168176
169177
170178
171
179
180
181
182
183
184
185
186
172187
173188
174189
175190
176191
177
178
179
180
192
193
194
195
196
181197
182198
183199
......
322338
323339
324340
325
341
326342
327
343
344
345
346
347
348
349
350
351
352
353
328354
329355
330356
331357
332
333
334
335
336
337
338358
339359
340360
......
347367
348368
349369
350
351
352
353
354
355
356
357
358
370
371
372
373
374
359375
360376
361377
378
379
362380
363381
364
382
383
384
385
386
387
388
389
365390
366391
367392
}
static struct env_struct *find_env(const char *name) {
struct env_struct *var;
if (setjmp(uterror) == -1) {
struct env_struct *var = NULL;
CEXCEPTION_T e = CEXCEPTION_NONE;
Try
{
HASH_FIND_STR( platform_env, name, var );
}
Catch(e)
{
#if DEBUG_PLATFORM
printf("find_env: Unable to find environement variable\n");
getc();
#endif
return NULL;
} else {
HASH_FIND_STR( platform_env, name, var );
}
return var;
}
return;
}
if (Type == kEnvPtr) {
if (!CopyVarPtr( var, ptr, size)) return;
if (!CopyVarPtr( var, ptr, size))
{
free(var);
return;
}
}
else if (Type == kEnvValue)
var->value = value;
var->Type = Type;
var->name = newString(name);
if (!var->name) {
if (!var->name) {
if (Type == kEnvPtr && var->ptr) free(var->ptr);
free(var);
return;
}
if (setjmp(uterror) == -1) {
CEXCEPTION_T e = CEXCEPTION_NONE;
Try
{
HASH_ADD_KEYPTR( hh, platform_env, name, strlen(var->name), var );
}
Catch(e)
{
printf("_set_env: Unable to set environement variable"); // don't try to acces to the string 'name',
//'cause we just returned from the longjump, stack as already changed state.
#if DEBUG_PLATFORM
getc();
#endif
return;
} else {
HASH_ADD_KEYPTR( hh, platform_env, name, strlen(var->name), var );
}
if (Type == kEnvPtr && var->ptr) free(var->ptr);
free(var->name);
free(var);
}
}
/* Warning: set_env will create a new variable each time it will be called,
return;
}
static void delete_env(struct env_struct *var) {
static void delete_env(struct env_struct *var) {
if (setjmp(uterror) == -1) {
CEXCEPTION_T e = CEXCEPTION_NONE;
Try
{
HASH_DEL( platform_env, var);
if (var->name) free(var->name);
if (var->Type == kEnvPtr && var->ptr) free(var->ptr);
free(var);
}
Catch(e)
{
printf("delete_env: Unable to delete environement variable\n");
#if DEBUG_PLATFORM
getc();
#endif
return;
} else {
HASH_DEL( platform_env, var);
if (var->name) free(var->name);
free(var);
}
}
}
void free_platform_env(void) {
struct env_struct *current_var, *tmp;
if (setjmp(uterror) == -1) {
printf("free_platform_env: Unable to delete all environement variables\n");
#if DEBUG_PLATFORM
getc();
#endif
return;
} else {
struct env_struct *current_var, *tmp;
CEXCEPTION_T e = CEXCEPTION_NONE;
Try
{
HASH_ITER(hh, platform_env, current_var, tmp) {
HASH_DEL(platform_env,current_var);
if (current_var->name) free(current_var->name);
if (current_var->Type == kEnvPtr && current_var->ptr) free(current_var->ptr);
}
free(current_var);
}
}
Catch(e)
{
printf("free_platform_env: Unable to delete all environement variables\n");
#if DEBUG_PLATFORM
getc();
#endif
}
}
#if DEBUG_PLATFORM

Archive Download the corresponding diff file

Revision: 2156