Chameleon

Chameleon Commit Details

Date:2010-01-17 01:19:53 (9 years 9 months ago)
Author:Rekursor
Commit:11
Parents: 10
Message:Renamed MALLOC to malloc and malloc with 3 params. to safe_malloc as discussed with Zef and others. diffs from trunk should also be shorter now.
Changes:
M/branches/rekursor/i386/boot2/graphics.c
M/branches/rekursor/i386/libsaio/cache.c
M/branches/rekursor/i386/libsa/libsa.h
M/branches/rekursor/i386/libsaio/bootstruct.c
M/branches/rekursor/i386/libsaio/ntfs.c
M/branches/rekursor/i386/libsaio/nvidia.c
M/branches/rekursor/i386/libsaio/ext2fs.c
M/branches/rekursor/i386/libsaio/pci.c
M/branches/rekursor/CHANGES
M/branches/rekursor/i386/libsaio/ati.c
M/branches/rekursor/i386/libsaio/device_tree.c
M/branches/rekursor/i386/libsaio/pci_root.c
M/branches/rekursor/i386/libsaio/stringTable.c
M/branches/rekursor/i386/libsaio/sys.c
M/branches/rekursor/i386/libsaio/nbp.c
M/branches/rekursor/i386/libsaio/hfs.c
M/branches/rekursor/i386/boot2/drivers.c
M/branches/rekursor/i386/libsaio/allocate.c
M/branches/rekursor/i386/libsaio/msdos.c
M/branches/rekursor/i386/libsaio/hfs_compare.c
M/branches/rekursor/i386/boot2/bmdecompress.c
M/branches/rekursor/i386/boot2/gui.c
M/branches/rekursor/i386/libsaio/fake_efi.c
M/branches/rekursor/i386/libsaio/disk.c
M/branches/rekursor/i386/libsaio/device_inject.c
M/branches/rekursor/i386/libsa/zalloc.c
M/branches/rekursor/i386/libsaio/ufs.c
M/branches/rekursor/i386/boot2/ramdisk.c
M/branches/rekursor/i386/boot2/options.c
M/branches/rekursor/i386/libsaio/xml.c
M/branches/rekursor/i386/boot2/picopng.c

File differences

branches/rekursor/CHANGES
1
2
13
24
3
5
46
5
6
7
8
9
10
711
8
12
13
14
- Now malloc (ex. MALLOC in Asere patch) is renamed malloc(size) and is an alias
to safe_malloc(size, file, line) with _FILE_ and _LINE_ prerocessor definitions
- Added a new 'Rename Partition Feature', now permitting to rename partition
like 'System reserved' to a more meaningful name
- Added SystemID option permitting to change the System UUID to a fixed/reproduceable value.
- Added SystemID option permitting to change the System UUID to a fixed value.
- Added the PciRoot autodetection feature imported from pcefi10.5
- Added automatic "system-id" injection from dmi bios, also compatible with SystemID boot option and former SMUUID from smbios,plist
- Added "system-type' automatic injection (1=Desktop) plus override possibility with the new system-type option in bootConfig
- Added automatic "system-id" injection from dmi bios, also compatible
with SystemID boot option and former SMUUID from smbios,plist
- Added "system-type' automatic injection (1=Desktop) plus override possibility
with the new system-type option in bootConfig
- Added SMserial and SMproductname new options for smbios.plist
- Merged with asere patch, while keeping my fake_efi.c changes, and adding a new stringForKey() API, also changed the DT__XXXX() set of functions to handle const char * values instead of char*.
- Merged with asere patch, while keeping my fake_efi.c changes, and adding a new
stringForKey() API, also changed the DT__XXXX() set of functions
to handle const char * values instead of char*.
branches/rekursor/i386/libsaio/xml.c
509509
510510
511511
512
512
513513
514514
515515
......
590590
591591
592592
593
593
594594
595595
596596
if (gTagsFree == 0)
{
#if USEMALLOC
tag = (TagPtr)MALLOC(kTagsPerBlock * sizeof(Tag));
tag = (TagPtr)malloc(kTagsPerBlock * sizeof(Tag));
#else
tag = (TagPtr)AllocateBootXMemory(kTagsPerBlock * sizeof(Tag));
#endif
if (symbol == 0)
{
#if USEMALLOC
symbol = (SymbolPtr)MALLOC(sizeof(Symbol) + 1 + strlen(string));
symbol = (SymbolPtr)malloc(sizeof(Symbol) + 1 + strlen(string));
#else
symbol = (SymbolPtr)AllocateBootXMemory(sizeof(Symbol) + 1 + strlen(string));
#endif
branches/rekursor/i386/libsaio/bootstruct.c
4848
4949
5050
51
52
51
52
5353
5454
5555
if ( !init_done )
{
bootArgs = (boot_args *)MALLOC(sizeof(boot_args));
bootInfo = (PrivateBootInfo_t *)MALLOC(sizeof(PrivateBootInfo_t));
bootArgs = (boot_args *)malloc(sizeof(boot_args));
bootInfo = (PrivateBootInfo_t *)malloc(sizeof(PrivateBootInfo_t));
if (bootArgs == 0 || bootInfo == 0)
stop("Couldn't allocate boot info\n");
branches/rekursor/i386/libsaio/ext2fs.c
2020
2121
2222
23
23
2424
2525
2626
void EX2GetDescription(CICell ih, char *str, long strMaxLen)
{
char * buf=MALLOC (EX2ProbeSize);
char * buf=malloc (EX2ProbeSize);
str[0]=0;
if (!buf)
return;
branches/rekursor/i386/libsaio/device_tree.c
6868
6969
7070
71
71
7272
7373
7474
......
117117
118118
119119
120
120
121121
122122
123123
......
276276
277277
278278
279
279
280280
281281
282282
......
342342
343343
344344
345
345
346346
347347
348348
DPRINTF("DT__AddProperty([Node '%s'], '%s', %d, 0x%x)\n", DT__GetName(node), name, length, value);
if (freeProperties == NULL) {
void *buf = MALLOC(kAllocSize);
void *buf = malloc(kAllocSize);
int i;
DPRINTF("Allocating more free properties\n");
Node *node;
if (freeNodes == NULL) {
void *buf = MALLOC(kAllocSize);
void *buf = malloc(kAllocSize);
int i;
DPRINTF("Allocating more free nodes\n");
buf = 0;
} else {
if (*buffer_p == 0) {
buf = MALLOC(totalSize);
buf = malloc(totalSize);
} else {
buf = *buffer_p;
}
}
if (child == 0 && createIfMissing) {
DPRINTF("Creating node\n");
char *str = MALLOC(strlen(nameBuf) + 1);
char *str = malloc(strlen(nameBuf) + 1);
// XXX this will leak
strcpy(str, nameBuf);
branches/rekursor/i386/libsaio/hfs.c
152152
153153
154154
155
156
157
155
156
157
158158
159
159
160160
161161
162162
163
163
164164
165165
166166
......
594594
595595
596596
597
597
598598
599599
600600
......
726726
727727
728728
729
729
730730
731731
732732
......
864864
865865
866866
867
867
868868
869869
870870
}
#ifdef __i386__
if (!gTempStr) gTempStr = (char *)MALLOC(4096);
if (!gLinkTemp) gLinkTemp = (char *)MALLOC(64);
if (!gBTreeHeaderBuffer) gBTreeHeaderBuffer = (char *)MALLOC(512);
if (!gTempStr) gTempStr = (char *)malloc(4096);
if (!gLinkTemp) gLinkTemp = (char *)malloc(64);
if (!gBTreeHeaderBuffer) gBTreeHeaderBuffer = (char *)malloc(512);
if (!gHFSMdbVib) {
gHFSMdbVib = (char *)MALLOC(kBlockSize);
gHFSMdbVib = (char *)malloc(kBlockSize);
gHFSMDB = (HFSMasterDirectoryBlock *)gHFSMdbVib;
}
if (!gHFSPlusHeader) {
gHFSPlusHeader = (char *)MALLOC(kBlockSize);
gHFSPlusHeader = (char *)malloc(kBlockSize);
gHFSPlus = (HFSPlusVolumeHeader *)gHFSPlusHeader;
}
if (!gTempStr || !gLinkTemp || !gBTreeHeaderBuffer ||
}
nodeSize = SWAP_BE16(gBTHeaders[kBTreeCatalog]->nodeSize);
nodeBuf = (char *)MALLOC(nodeSize);
nodeBuf = (char *)malloc(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
index = *dirIndex % nodeSize;
curNode = SWAP_BE32(gBTHeaders[btree]->rootNode);
nodeSize = SWAP_BE16(gBTHeaders[btree]->nodeSize);
nodeBuf = (char *)MALLOC(nodeSize);
nodeBuf = (char *)malloc(nodeSize);
node = (BTNodeDescriptor *)nodeBuf;
while (1) {
}
if (extentBuffer == 0) {
extentBuffer = MALLOC(sizeofExtent * extentDensity);
extentBuffer = malloc(sizeofExtent * extentDensity);
if (extentBuffer == 0) return -1;
}
branches/rekursor/i386/libsaio/allocate.c
3939
4040
4141
42
42
4343
4444
4545
46
46
4747
4848
4949
char *nameBuf;
uint32_t *buffer;
nameBuf = MALLOC(strlen(rangeName) + 1);
nameBuf = malloc(strlen(rangeName) + 1);
if (nameBuf == 0) return -1;
strcpy(nameBuf, rangeName);
buffer = MALLOC(2 * sizeof(uint32_t));
buffer = malloc(2 * sizeof(uint32_t));
if (buffer == 0) return -1;
buffer[0] = start;
branches/rekursor/i386/libsaio/hfs_compare.c
3535
3636
3737
38
38
3939
4040
4141
static unsigned short *
UncompressStructure(struct compressed_block *bp, int count, int size)
{
unsigned short *out = MALLOC(size);
unsigned short *out = malloc(size);
unsigned short *op = out;
unsigned short data;
int i, j;
branches/rekursor/i386/libsaio/ufs.c
127127
128128
129129
130
131
132
133
134
135
130
131
132
133
134
135
136136
137137
138138
......
168168
169169
170170
171
171
172172
173173
174174
gCurrentIH = 0;
#ifdef __i386__
if (!gULBuf) gULBuf = (char *) MALLOC(UFS_LABEL_SIZE);
if (!gFSBuf) gFSBuf = (char *) MALLOC(SBSIZE);
if (!gTempName) gTempName = (char *) MALLOC(MAXNAMLEN + 1);
if (!gTempName2) gTempName2 = (char *) MALLOC(MAXNAMLEN + 1);
if (!gRootInodePtr) gRootInodePtr = (InodePtr) MALLOC(sizeof(Inode));
if (!gFileInodePtr) gFileInodePtr = (InodePtr) MALLOC(sizeof(Inode));
if (!gULBuf) gULBuf = (char *) malloc(UFS_LABEL_SIZE);
if (!gFSBuf) gFSBuf = (char *) malloc(SBSIZE);
if (!gTempName) gTempName = (char *) malloc(MAXNAMLEN + 1);
if (!gTempName2) gTempName2 = (char *) malloc(MAXNAMLEN + 1);
if (!gRootInodePtr) gRootInodePtr = (InodePtr) malloc(sizeof(Inode));
if (!gFileInodePtr) gFileInodePtr = (InodePtr) malloc(sizeof(Inode));
if (!gULBuf || !gFSBuf || !gTempName || !gTempName2 ||
!gRootInodePtr || !gFileInodePtr) return -1;
#endif
gFragSize = gFS->fs_fsize;
gFragsPerBlock = gBlockSize / gFragSize;
if (gTempBlock != 0) free(gTempBlock);
gTempBlock = MALLOC(gBlockSize);
gTempBlock = malloc(gBlockSize);
CacheInit(ih, gBlockSize);
gCurrentIH = ih;
branches/rekursor/i386/libsaio/pci_root.c
9292
9393
9494
95
95
9696
9797
9898
}
fsize = file_size(fd);
if ((new_dsdt = MALLOC(fsize)) == NULL) {
if ((new_dsdt = malloc(fsize)) == NULL) {
verbose("[ERROR] alloc DSDT memory failed\n");
close (fd);
goto out;
branches/rekursor/i386/libsaio/device_inject.c
7272
7373
7474
75
75
7676
7777
7878
......
159159
160160
161161
162
162
163163
164164
165165
......
179179
180180
181181
182
182
183183
184184
185185
......
260260
261261
262262
263
263
264264
265265
266
266
267267
268268
269269
......
276276
277277
278278
279
279
280280
281281
282282
......
306306
307307
308308
309
309
310310
311311
312312
......
320320
321321
322322
323
323
324324
325325
326326
......
332332
333333
334334
335
335
336336
337337
338338
......
427427
428428
429429
430
430
431431
432432
433433
......
439439
440440
441441
442
442
443443
444444
445445
if (len > 1)
{
// the resulting binary will be the half size of the input hex string
binStr = MALLOC(len / 2);
binStr = malloc(len / 2);
binStrIdx = 0;
hexNibbleIdx = 0;
for (hexStrIdx = 0; hexStrIdx < len; hexStrIdx++)
struct DevPropString *devprop_create_string(void)
{
string = (struct DevPropString*)MALLOC(sizeof(struct DevPropString));
string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
if(string == NULL)
return NULL;
if (string == NULL || path == NULL) {
return NULL;
}
device = MALLOC(sizeof(struct DevPropDevice));
device = malloc(sizeof(struct DevPropDevice));
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
printf("ERROR parsing device path\n");
string->length += device->length;
if(!string->entries)
if((string->entries = (struct DevPropDevice**)MALLOC(sizeof(device)))== NULL)
if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)))== NULL)
return 0;
string->entries[string->numentries++] = (struct DevPropDevice*)MALLOC(sizeof(device));
string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device));
string->entries[string->numentries-1] = device;
return device;
return 0;
uint32_t length = ((strlen(nm) * 2) + len + (2 * sizeof(uint32_t)) + 2);
uint8_t *data = (uint8_t*)MALLOC(length);
uint8_t *data = (uint8_t*)malloc(length);
{
if(!data)
return 0;
uint32_t offset = device->length - (24 + (6 * device->num_pci_devpaths));
uint8_t *newdata = (uint8_t*)MALLOC((length + offset));
uint8_t *newdata = (uint8_t*)malloc((length + offset));
if(!newdata)
return 0;
if(device->data)
device->numentries++;
if(!device->data)
device->data = (uint8_t*)MALLOC(sizeof(uint8_t));
device->data = (uint8_t*)malloc(sizeof(uint8_t));
else
free(device->data);
char *devprop_generate_string(struct DevPropString *string)
{
char *buffer = (char*)MALLOC(string->length * 2);
char *buffer = (char*)malloc(string->length * 2);
char *ptr = buffer;
if(!buffer)
void set_eth_builtin(pci_dt_t *eth_dev)
{
char *devicepath = get_pci_dev_path(eth_dev);
struct DevPropDevice *device = (struct DevPropDevice*)MALLOC(sizeof(struct DevPropDevice));
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
{
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)MALLOC(sizeof(uint8_t) * string->length);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
branches/rekursor/i386/libsaio/ntfs.c
157157
158158
159159
160
160
161161
162162
163163
size_t nameSize;
char *buf;
buf = (char *)MALLOC(MAX_CLUSTER_SIZE);
buf = (char *)malloc(MAX_CLUSTER_SIZE);
if (buf == 0) {
goto error;
}
branches/rekursor/i386/libsaio/nvidia.c
612612
613613
614614
615
615
616616
617617
618618
......
703703
704704
705705
706
706
707707
708708
709709
(REG32(0) >> 20) & 0x1ff, nvda_dev->vendor_id, nvda_dev->device_id,
devicepath);
rom = MALLOC(NVIDIA_ROM_SIZE);
rom = malloc(NVIDIA_ROM_SIZE);
sprintf(nvFilename, "/Extra/%04x_%04x.rom", (uint16_t)nvda_dev->vendor_id, (uint16_t)nvda_dev->device_id);
if (getBoolForKey(kUseNvidiaROM, &doit, &bootInfo->bootConfig) && doit) {
verbose("Looking for nvidia video bios file %s\n", nvFilename);
devprop_add_value(device, "vbios", rom, (nvBiosOveride > 0) ? nvBiosOveride : (rom[2] * 512));
}
stringdata = MALLOC(sizeof(uint8_t) * string->length);
stringdata = malloc(sizeof(uint8_t) * string->length);
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
branches/rekursor/i386/libsaio/ati.c
290290
291291
292292
293
293
294294
295295
296296
......
420420
421421
422422
423
423
424424
425425
426426
......
698698
699699
700700
701
701
702702
703703
704704
......
754754
755755
756756
757
757
758758
759759
760760
REG32W(0xa8, 0);
REG32R(0xac);
BIOSBase = MALLOC(0x10000);
BIOSBase = malloc(0x10000);
REG32W(0xa8, 0);
BIOSBase[0] = REG32R(0xac);
counter = 4;
return 0;
}
printf("dumping pci config space, 256 bytes\n");
config_space = MALLOC(256);
config_space = malloc(256);
for (i=0; i<=255; i++) {
config_space[i] = pci_config_read8( ati_dev->dev.addr, i);
}
sprintf(tmp, "/Extra/%04x_%04x.rom", (uint16_t)ati_dev->vendor_id, (uint16_t)ati_dev->device_id);
if (getBoolForKey(kUseAtiROM, &doit, &bootInfo->bootConfig) && doit) {
verbose("looking for ati video bios file %s\n", tmp);
rom = MALLOC(0x20000);
rom = malloc(0x20000);
rom_size = load_ati_bios_file(tmp, rom, 0x20000);
if (rom_size > 0x10000) {
rom_size = 0x10000; //we dont need rest anyway;
if (toFree) {
free(bios);
}
stringdata = MALLOC(sizeof(uint8_t) * string->length);
stringdata = malloc(sizeof(uint8_t) * string->length);
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
branches/rekursor/i386/libsaio/sys.c
326326
327327
328328
329
329
330330
331331
332332
......
621621
622622
623623
624
624
625625
626626
627627
......
649649
650650
651651
652
652
653653
654654
655655
const char * entryName;
if (gMakeDirSpec == 0)
gMakeDirSpec = (char *)MALLOC(1024);
gMakeDirSpec = (char *)malloc(1024);
if (!dirSpec) {
long idx, len;
{
struct dirstuff * dirp = 0;
dirp = (struct dirstuff *) MALLOC(sizeof(struct dirstuff));
dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff));
if (dirp == NULL)
goto error;
if ((bvr = getBootVolumeRef(path, &dirPath)) == NULL)
goto error;
dirp = (struct dirstuff *) MALLOC(sizeof(struct dirstuff));
dirp = (struct dirstuff *) malloc(sizeof(struct dirstuff));
if (dirp == NULL)
goto error;
branches/rekursor/i386/libsaio/nbp.c
120120
121121
122122
123
123
124124
125125
126126
if ( !gNetBVR )
{
gNetBVR = MALLOC( sizeof(*gNetBVR) );
gNetBVR = malloc( sizeof(*gNetBVR) );
if ( gNetBVR )
{
bzero(gNetBVR, sizeof(*gNetBVR));
branches/rekursor/i386/libsaio/disk.c
501501
502502
503503
504
504
505505
506506
507507
......
570570
571571
572572
573
573
574574
575575
576576
......
651651
652652
653653
654
654
655655
656656
657657
......
751751
752752
753753
754
754
755755
756756
757757
......
977977
978978
979979
980
980
981981
982982
983983
......
988988
989989
990990
991
991
992992
993993
994994
......
999999
10001000
10011001
1002
1002
10031003
10041004
10051005
......
10751075
10761076
10771077
1078
1078
10791079
10801080
10811081
......
11291129
11301130
11311131
1132
1132
11331133
11341134
11351135
......
12241224
12251225
12261226
1227
1227
12281228
12291229
12301230
......
12321232
12331233
12341234
1235
1235
12361236
12371237
12381238
......
15741574
15751575
15761576
1577
1577
15781578
15791579
15801580
......
17591759
17601760
17611761
1762
1762
17631763
17641764
17651765
......
17961796
17971797
17981798
1799
1799
18001800
18011801
18021802
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
BVFree bvFreeFunc,
int probe, int type, unsigned int bvrFlags )
{
BVRef bvr = (BVRef) MALLOC( sizeof(*bvr) );
BVRef bvr = (BVRef) malloc( sizeof(*bvr) );
if ( bvr )
{
bzero(bvr, sizeof(*bvr));
do {
// Create a new mapping.
map = (struct DiskBVMap *) MALLOC( sizeof(*map) );
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( map )
{
map->biosdev = biosdev;
struct Block0 *block0_p;
unsigned int blksize;
unsigned int factor;
void *buffer = MALLOC(BPS);
void *buffer = malloc(BPS);
/* Check for alternate block size */
if (readBytes( biosdev, 0, 0, BPS, buffer ) != 0) {
blksize = OSSwapBigToHostInt16(block0_p->sbBlkSize);
if (blksize != BPS) {
free(buffer);
buffer = MALLOC(blksize);
buffer = malloc(blksize);
}
factor = blksize / BPS;
} else {
do {
// Create a new mapping.
map = (struct DiskBVMap *) MALLOC( sizeof(*map) );
map = (struct DiskBVMap *) malloc( sizeof(*map) );
if ( map )
{
int error;
int fatbits;
// Allocating buffer for 4 sectors.
const void * probeBuffer = MALLOC(PROBEFS_SIZE);
const void * probeBuffer = malloc(PROBEFS_SIZE);
if (probeBuffer == NULL)
goto exit;
static BVRef diskScanGPTBootVolumes( int biosdev, int * countPtr )
{
struct DiskBVMap * map = NULL;
void *buffer = MALLOC(BPS);
void *buffer = malloc(BPS);
int error;
if ( error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer ) != 0) {
verbose("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error);
UInt32 bufferSize = IORound(gptCount * gptSize, BPS);
if(bufferSize == 0)
goto scanErr;
buffer = MALLOC(bufferSize);
buffer = malloc(bufferSize);
if(readBytes(biosdev, gptBlock, 0, bufferSize, buffer) != 0)
goto scanErr;
verbose("Read GPT\n");
// Allocate a new map for this BIOS device and insert it into the chain
map = MALLOC(sizeof(*map));
map = malloc(sizeof(*map));
map->biosdev = biosdev;
map->bvr = NULL;
map->bvrcnt = 0;
/*
* Allocate and copy the matched bvr entry into a new one.
*/
newBVR = (BVRef) MALLOC(sizeof(*newBVR));
newBVR = (BVRef) malloc(sizeof(*newBVR));
bcopy(bvr, newBVR, sizeof(*newBVR));
/*
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) MALLOC(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
if ( gBootSector == NULL ) return -1;
}
bootSector = gBootSector;
{
if ( gBootSector == NULL )
{
gBootSector = (struct disk_blk0 *) MALLOC(sizeof(*gBootSector));
gBootSector = (struct disk_blk0 *) malloc(sizeof(*gBootSector));
if ( gBootSector == NULL ) return -1;
}
bootSector = (struct disk_boot1f32_blk *) gBootSector;
branches/rekursor/i386/libsaio/cache.c
9090
9191
9292
93
94
93
94
9595
9696
9797
gCacheIH = ih;
#ifdef __i386__
if (!gCacheBuffer) gCacheBuffer = (char *) MALLOC(kCacheSize);
if (!gCacheEntries) gCacheEntries = (CacheEntry *) MALLOC(kCacheMaxEntries * sizeof(CacheEntry));
if (!gCacheBuffer) gCacheBuffer = (char *) malloc(kCacheSize);
if (!gCacheEntries) gCacheEntries = (CacheEntry *) malloc(kCacheMaxEntries * sizeof(CacheEntry));
if ( !gCacheBuffer || !gCacheEntries )
{
gCacheIH = 0; // invalidate cache
branches/rekursor/i386/libsaio/pci.c
8181
8282
8383
84
84
8585
8686
8787
......
111111
112112
113113
114
114
115115
116116
117117
if (!id || id == 0xffffffff) {
continue;
}
new = (pci_dt_t*)MALLOC(sizeof(pci_dt_t));
new = (pci_dt_t*)malloc(sizeof(pci_dt_t));
bzero(new, sizeof(pci_dt_t));
new->dev.addr= pci_addr;
new->vendor_id= id & 0xffff;
void build_pci_dt(void)
{
root_pci_dev = MALLOC(sizeof(pci_dt_t));
root_pci_dev = malloc(sizeof(pci_dt_t));
bzero(root_pci_dev, sizeof(pci_dt_t));
scan_pci_bus(root_pci_dev, 0);
#if DEBUG_PCI
branches/rekursor/i386/libsaio/stringTable.c
9999
100100
101101
102
102
103103
104104
105105
......
157157
158158
159159
160
160
161161
162162
163163
......
234234
235235
236236
237
237
238238
239239
240240
......
271271
272272
273273
274
274
275275
276276
277277
......
553553
554554
555555
556
556
557557
558558
559559
......
711711
712712
713713
714
714
715715
716716
717717
len = strlen(key);
tab = (char *)table;
buf = (char *)MALLOC(len + 3);
buf = (char *)malloc(len + 3);
sprintf(buf, "\"%s\"", key);
len = strlen(buf);
if (begin == end)
return 0;
bufsize = end - begin + 1;
newstr = MALLOC(bufsize);
newstr = malloc(bufsize);
strlcpy(newstr, begin, bufsize);
*list = end;
*size = newsize;
int size;
if (getValueForConfigTableKey(config, key, &val, &size)) {
newstr = (char *)MALLOC(size+1);
newstr = (char *)malloc(size+1);
for (p = newstr; size; size--, p++, val++) {
if ((*p = *val) == '\\') {
switch (*++val) {
int size;
if (getValueForKey(key, &val, &size, config) && size) {
newstr = (char *)MALLOC(size + 1);
newstr = (char *)malloc(size + 1);
strlcpy(newstr, val, size + 1);
return newstr;
} else {
pos = 0;
char *configBuffer;
configBuffer = MALLOC(strlen(buffer)+1);
configBuffer = malloc(strlen(buffer)+1);
strcpy(configBuffer, buffer);
while (1)
char * newString(const char * oldString)
{
if ( oldString )
return strcpy(MALLOC(strlen(oldString)+1), oldString);
return strcpy(malloc(strlen(oldString)+1), oldString);
else
return NULL;
}
branches/rekursor/i386/libsaio/msdos.c
155155
156156
157157
158
158
159159
160160
161161
......
629629
630630
631631
632
632
633633
634634
635
635
636636
637637
638638
......
664664
665665
666666
667
667
668668
669669
670670
671671
672672
673673
674
674
675675
676676
677677
......
724724
725725
726726
727
727
728728
729729
730730
......
773773
774774
775775
776
776
777777
778778
779779
......
865865
866866
867867
868
868
869869
870870
871871
......
886886
887887
888888
889
889
890890
891891
892892
......
906906
907907
908908
909
909
910910
911911
912912
return 0;
}
buf=MALLOC (512);
buf=malloc (512);
/*
* Read the boot sector of the filesystem, and then check the
* boot signature. If not a dos boot sector then error out.
st = (struct msdosdirstate *)*dirIndex;
if (!st)
{
st=MALLOC (sizeof (*st));
st=malloc (sizeof (*st));
if (dirPath[0])
{
uint8_t *buf=MALLOC(msdosclustersize);
uint8_t *buf=malloc(msdosclustersize);
dirp = getdirpfrompath (ih, dirPath, buf);
if (!dirp || !(dirp->deAttributes & ATTR_DIRECTORY))
{
{
int i;
for (i=0;vfatname[i];i++);
*name = MALLOC (256);
*name = malloc (256);
utf_encodestr(vfatname, i, (u_int8_t *)*name, 255, OSLittleEndian );
}
else
{
int i, j, k;
uint16_t tmp[13];
*name = MALLOC (26);
*name = malloc (26);
for (i=7;i>=0;i--)
if (dirp->deName[i]!=' ')
break;
return -1;
if (filePath[0] == '/')
filePath++;
buf = MALLOC(msdosclustersize);
buf = malloc(msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
return -1;
if (filePath[0] == '/')
filePath++;
buf = MALLOC(msdosclustersize);
buf = malloc(msdosclustersize);
dirp = getdirpfrompath (ih, filePath, buf);
if (!dirp || (dirp->deAttributes & ATTR_DIRECTORY))
{
label[0] = '\0';
initRoot (&st);
st.buf = MALLOC(msdosclustersize);
st.buf = malloc(msdosclustersize);
while ((dirp = getnextdirent (ih, vfatlabel, &st)))
if (dirp->deAttributes & ATTR_VOLUME) {
strncpy((char *)label, (char *)dirp->deName, LABEL_LENGTH);
/* else look in the boot blocks */
if (!labelfound || str[0] == '\0') {
char *buf = MALLOC (512);
char *buf = malloc (512);
union bootsector *bsp = (union bootsector *)buf;
Seek(ih, 0);
Read(ih, (long)buf, 512);
long
MSDOSGetUUID(CICell ih, char *uuidStr)
{
char *buf = MALLOC (512);
char *buf = malloc (512);
union bootsector *bsp = (union bootsector *)buf;
if (MSDOSInitPartition (ih)<0)
branches/rekursor/i386/libsaio/fake_efi.c
5757
5858
5959
60
60
6161
6262
6363
......
339339
340340
341341
342
342
343343
344344
345345
static inline char * mallocStringForGuid(EFI_GUID const *pGuid)
{
char *string = MALLOC(37);
char *string = malloc(37);
efi_guid_unparse_upper(pGuid, string);
return string;
}
if (!key || !(*key) || !len || !src) return 0;
*len = strlen(src);
dst = (EFI_CHAR16*) MALLOC(((*len)+1)*2);
dst = (EFI_CHAR16*) malloc(((*len)+1)*2);
for (; i<*len; i++) dst[i] = src[i];
dst[*len] = '\0';
branches/rekursor/i386/boot2/picopng.c
4545
4646
4747
48
48
4949
5050
5151
......
7373
7474
7575
76
76
7777
7878
7979
png_alloc_node_t *node;
if (png_alloc_find_node(addr))
return;
node = MALLOC(sizeof (png_alloc_node_t));
node = malloc(sizeof (png_alloc_node_t));
node->addr = addr;
node->size = size;
node->prev = png_alloc_tail;
void *png_alloc_malloc(size_t size)
{
void *addr = MALLOC(size);
void *addr = malloc(size);
png_alloc_add_node(addr, size);
return addr;
}
branches/rekursor/i386/boot2/graphics.c
5252
5353
5454
55
55
5656
5757
5858
......
151151
152152
153153
154
154
155155
156156
157157
......
349349
350350
351351
352
352
353353
354354
355355
......
483483
484484
485485
486
486
487487
488488
489489
......
491491
492492
493493
494
494
495495
496496
497497
......
499499
500500
501501
502
502
503503
504504
505505
......
525525
526526
527527
528
528
529529
530530
531531
......
543543
544544
545545
546
546
547547
548548
549549
......
575575
576576
577577
578
578
579579
580580
581581
{
VBEInfoBlock vbeInfo;
int err, small;
char *buff = MALLOC(sizeof(char)*256);
char *buff = malloc(sizeof(char)*256);
if(!buff) return 0;
bzero( &vbeInfo, sizeof(vbeInfo) );
if ( err != errSuccess )
return 0;
char *buff=MALLOC(sizeof(char)*3072);
char *buff=malloc(sizeof(char)*3072);
if(!buff) return 0;
// Loop through the mode list, and find the matching mode.
unsigned char value;
} * bp = (struct RLEBlock *) rleData;
out = cp = MALLOC( outBytes );
out = cp = malloc( outBytes );
if ( out == NULL ) return NULL;
while ( rleBlocks-- )
switch ( VIDEO(depth) ) {
case 16 :
img16 = MALLOC(width * height * 2);
img16 = malloc(width * height * 2);
if ( !img16 ) break;
for (cnt = 0; cnt < (width * height); cnt++)
img16[cnt] = lookUpCLUTIndex(imageData[cnt], 16);
break;
case 32 :
img32 = MALLOC(width * height * 4);
img32 = malloc(width * height * 4);
if ( !img32 ) break;
for (cnt = 0; cnt < (width * height); cnt++)
img32[cnt] = lookUpCLUTIndex(imageData[cnt], 32);
break;
default :
img = MALLOC(width * height);
img = malloc(width * height);
bcopy(imageData, img, width * height);
break;
}
error = -1;
goto failed;
}
pngData = MALLOC(pngSize);
pngData = malloc(pngSize);
if (read(pngFile, (char *) pngData, pngSize) != pngSize) {
error = -1;
goto failed;
error = -1;
goto failed;
}
uint8_t *result = MALLOC(info->width*4*info->height);
uint8_t *result = malloc(info->width*4*info->height);
*width = info->width;
*height = info->height;
memcpy(result, info->image->data, info->width*4*info->height);
error = -1;
goto failed;
}
uint8_t *result = MALLOC(info->width*4*info->height);
uint8_t *result = malloc(info->width*4*info->height);
*width = info->width;
*height = info->height;
memcpy(result, info->image->data, info->width*4*info->height);
branches/rekursor/i386/boot2/drivers.c
145145
146146
147147
148
149
150
151
152
148
149
150
151
152
153153
154154
155155
......
434434
435435
436436
437
437
438438
439439
440440
......
442442
443443
444444
445
445
446446
447447
448448
......
456456
457457
458458
459
459
460460
461461
462462
......
471471
472472
473473
474
474
475475
476476
477477
......
727727
728728
729729
730
730
731731
732732
733733
......
784784
785785
786786
787
787
788788
789789
790790
static long
InitDriverSupport( void )
{
gExtensionsSpec = MALLOC( 4096 );
gDriverSpec = MALLOC( 4096 );
gFileSpec = MALLOC( 4096 );
gTempSpec = MALLOC( 4096 );
gFileName = MALLOC( 4096 );
gExtensionsSpec = malloc( 4096 );
gDriverSpec = malloc( 4096 );
gFileSpec = malloc( 4096 );
gTempSpec = malloc( 4096 );
gFileName = malloc( 4096 );
if ( !gExtensionsSpec || !gDriverSpec || !gFileSpec || !gTempSpec || !gFileName )
stop("InitDriverSupport error");
(bundleType == kCFBundleType2) ? "Contents/MacOS/" : "");
executablePathLength = strlen(gFileSpec) + 1;
tmpExecutablePath = MALLOC(executablePathLength);
tmpExecutablePath = malloc(executablePathLength);
if (tmpExecutablePath == 0) break;
strcpy(tmpExecutablePath, gFileSpec);
sprintf(gFileSpec, "%s/%s", dirSpec, name);
bundlePathLength = strlen(gFileSpec) + 1;
tmpBundlePath = MALLOC(bundlePathLength);
tmpBundlePath = malloc(bundlePathLength);
if (tmpBundlePath == 0) break;
strcpy(tmpBundlePath, gFileSpec);
if (length == -1) break;
length = length + 1;
buffer = MALLOC(length);
buffer = malloc(length);
if (buffer == 0) break;
strlcpy(buffer, (char *)kLoadAddr, length);
module->executablePath = tmpExecutablePath;
module->bundlePath = tmpBundlePath;
module->bundlePathLength = bundlePathLength;
module->plistAddr = MALLOC(length);
module->plistAddr = malloc(length);
if ((module->executablePath == 0) || (module->bundlePath == 0) || (module->plistAddr == 0))
break;
return -2;
}
tmpModule = MALLOC(sizeof(Module));
tmpModule = malloc(sizeof(Module));
if (tmpModule == 0)
{
XMLFreeTag(moduleDict);
#endif
uncompressed_size = OSSwapBigToHostInt32(kernel_header->uncompressed_size);
binary = buffer = MALLOC(uncompressed_size);
binary = buffer = malloc(uncompressed_size);
size = decompress_lzss((u_int8_t *) binary, &kernel_header->data[0],
OSSwapBigToHostInt32(kernel_header->compressed_size));
branches/rekursor/i386/boot2/bmdecompress.c
3434
3535
3636
37
38
39
40
37
38
39
40
4141
4242
4343
......
135135
136136
137137
138
139
140
141
138
139
140
141
142142
143143
144144
......
238238
239239
240240
241
241
242242
243243
244244
int i, j;
uint32_t * input;
uint16_t * sc0 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc1 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc2 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc3 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc0 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
int i, j;
uint32_t * input;
uint16_t * sc0 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc1 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc2 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc3 = MALLOC((width+2) * sizeof(uint16_t));
uint16_t * sc0 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc1 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc2 = malloc((width+2) * sizeof(uint16_t));
uint16_t * sc3 = malloc((width+2) * sizeof(uint16_t));
uint32_t sr0, sr1, sr2, sr3;
bzero(sc0, (width+2) * sizeof(uint16_t));
*dw = (int) src[1];
*dh = (int) src[2];
ret = MALLOC ((*dw * *dh * *bitsPerPixel)/ 8);
ret = malloc ((*dw * *dh * *bitsPerPixel)/ 8);
switch(*bitsPerPixel)
{
branches/rekursor/i386/boot2/gui.c
158158
159159
160160
161
161
162162
163163
164164
......
191191
192192
193193
194
194
195195
196196
197197
......
259259
260260
261261
262
262
263263
264264
265
265
266266
267267
268268
......
284284
285285
286286
287
287
288288
289289
290290
291
291
292292
293293
294294
......
304304
305305
306306
307
307
308308
309309
310310
311
311
312312
313313
314314
......
916916
917917
918918
919
919
920920
921921
922922
......
10011001
10021002
10031003
1004
1004
10051005
10061006
10071007
......
10881088
10891089
10901090
1091
1091
10921092
10931093
10941094
......
12381238
12391239
12401240
1241
1241
12421242
12431243
12441244
12451245
1246
1246
12471247
12481248
12491249
......
14971497
14981498
14991499
1500
1500
15011501
15021502
15031503
for (i=0; i < sizeof(images) / sizeof(images[0]); i++) {
if (strcmp(image, images[i].name) == 0) {
if (images[i].image == NULL) {
images[i].image = MALLOC(sizeof(pixmap_t));
images[i].image = malloc(sizeof(pixmap_t));
}
width = 0;
height = 0;
for (i=0; i < sizeof(images) / sizeof(images[0]); i++) {
if (strcmp(image, images[i].name) == 0) {
if (images[i].image == NULL) {
images[i].image = MALLOC(sizeof(pixmap_t));
images[i].image = malloc(sizeof(pixmap_t));
}
sprintf(dirspec,"/Extra/Themes/%s/%s.png", theme_name, image);
width = 0;
pixmap_t *getCroppedPixmapAtPosition( pixmap_t *from, position_t pos, uint16_t width, uint16_t height )
{
pixmap_t *cropped = MALLOC( sizeof( pixmap_t ) );
pixmap_t *cropped = malloc( sizeof( pixmap_t ) );
if( !cropped )
return 0;
cropped->pixels = MALLOC( width * height * 4 );
cropped->pixels = malloc( width * height * 4 );
if ( !cropped->pixels )
return 0;
int createBackBuffer( window_t *window )
{
gui.backbuffer = MALLOC(sizeof(pixmap_t));
gui.backbuffer = malloc(sizeof(pixmap_t));
if(!gui.backbuffer)
return 1;
gui.backbuffer->pixels = MALLOC( window->width * window->height * 4 );
gui.backbuffer->pixels = malloc( window->width * window->height * 4 );
if(!gui.backbuffer->pixels)
{
free(gui.backbuffer);
int createWindowBuffer( window_t *window )
{
window->pixmap = MALLOC(sizeof(pixmap_t));
window->pixmap = malloc(sizeof(pixmap_t));
if(!window->pixmap)
return 1;
window->pixmap->pixels = MALLOC( window->width * window->height * 4 );
window->pixmap->pixels = malloc( window->width * window->height * 4 );
if(!window->pixmap->pixels)
{
free(window->pixmap);
struct putc_info pi;
if ((formattedtext = MALLOC(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL) {
// format the text
va_start(ap, fmt);
pi.str = formattedtext;
struct putc_info pi;
if ((formattedtext = MALLOC(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL) {
// format the text
va_start(ap, fmt);
pi.str = formattedtext;
position_torigin, cursor, bounds;
font_t *font = &font_console;
if ((formattedtext = MALLOC(1024)) != NULL) {
if ((formattedtext = malloc(1024)) != NULL) {
// format the text
pi.str = formattedtext;
pi.last_str = 0;
{
end = x + 1;
if( (font->chars[count] = MALLOC(sizeof(pixmap_t)) ) )
if( (font->chars[count] = malloc(sizeof(pixmap_t)) ) )
{
font->chars[count]->width = ( end - start) - 1;
font->chars[count]->height = font->height;
if ( ( font->chars[count]->pixels = MALLOC( font->chars[count]->width * data->image->height * 4) ) )
if ( ( font->chars[count]->pixels = malloc( font->chars[count]->width * data->image->height * 4) ) )
{
space += ( font->chars[count]->width * data->image->height * 4 );
// we skip the first line because there are just the red pixels for the char width
return;
pixmap_t progressbar;
progressbar.pixels=MALLOC(width * 4 * buff->height);
progressbar.pixels=malloc(width * 4 * buff->height);
if(!progressbar.pixels)
return;
branches/rekursor/i386/boot2/ramdisk.c
7373
7474
7575
76
77
76
77
7878
7979
8080
strcpy(gRAMDiskFile, param);
// Set gMI as well for the multiboot ramdisk driver hook.
gMI = gRAMDiskMI = MALLOC(sizeof(multiboot_info));
struct multiboot_module * ramdisk_module = MALLOC(sizeof(multiboot_module));
gMI = gRAMDiskMI = malloc(sizeof(multiboot_info));
struct multiboot_module * ramdisk_module = malloc(sizeof(multiboot_module));
// Fill in multiboot info and module structures.
if (gRAMDiskMI != NULL && ramdisk_module != NULL)
branches/rekursor/i386/boot2/options.c
631631
632632
633633
634
634
635635
636636
637637
......
776776
777777
778778
779
779
780780
781781
782
782
783783
784
784
785785
786786
787787
......
849849
850850
851851
852
852
853853
854854
855855
......
11411141
11421142
11431143
1144
1144
11451145
11461146
11471147
......
12171217
12181218
12191219
1220
1220
12211221
12221222
12231223
......
14291429
14301430
14311431
1432
1432
14331433
14341434
14351435
{
int i;
MemoryRange *mp = bootInfo->memoryMap;
char *buff = MALLOC(sizeof(char)*1024);
char *buff = malloc(sizeof(char)*1024);
if(!buff) return 0;
char info[] = "BIOS reported memory ranges:\n";
if (getValueForKey(kCDROMPromptKey, &val, &cnt, &bootInfo->bootConfig)) {
cnt += 1;
prompt = MALLOC(cnt);
prompt = malloc(cnt);
strlcpy(prompt, val, cnt);
} else {
name = MALLOC(80);
name = malloc(80);
getBootVolumeDescription(gBootVolume, name, 80, false);
prompt = MALLOC(256);
prompt = malloc(256);
sprintf(prompt, "Press any key to start up from %s, or press F8 to enter startup options.", name);
free(name);
cnt = 0;
if (gDeviceCount) {
// Allocate memory for an array of menu items.
menuItems = MALLOC(sizeof(MenuItem) * gDeviceCount);
menuItems = malloc(sizeof(MenuItem) * gDeviceCount);
if (menuItems == NULL) {
goto done;
}
char * configKernelFlags;
char * valueBuffer;
valueBuffer = MALLOC(VALUE_SIZE);
valueBuffer = malloc(VALUE_SIZE);
skipblanks( &cp );
val = "";
cnt = 0;
}
configKernelFlags = MALLOC(cnt + 1);
configKernelFlags = malloc(cnt + 1);
strlcpy(configKernelFlags, val, cnt + 1);
if (processBootArgument(kBootUUIDKey, cp, configKernelFlags, bootInfo->config, &argP, &cntRemaining, 0)) {
if (size > MAX_TEXT_FILE_SIZE) {
size = MAX_TEXT_FILE_SIZE;
}
buf = MALLOC(size);
buf = malloc(size);
read(fd, buf, size);
close(fd);
showTextBuffer(buf, size);
branches/rekursor/i386/libsa/libsa.h
126126
127127
128128
129
129
130130
131
131
132132
133133
134134
/*
* zalloc.c
*/
#define MALLOC(size)malloc(size, __FILE__, __LINE__)
#define malloc(size)safe_malloc(size, __FILE__, __LINE__)
extern void malloc_init(char * start, int size, int nodes, void (*malloc_error)(char *, size_t, const char *, int));
extern void * malloc(size_t size,const char *file, int line);
extern void * safe_malloc(size_t size,const char *file, int line);
extern void free(void * start);
extern void * realloc(void * ptr, size_t size);
branches/rekursor/i386/libsa/zalloc.c
8686
8787
8888
89
89
9090
9191
9292
......
315315
316316
317317
318
318
319319
320320
321321
#define BEST_FIT 1
void * malloc(size_t size, const char *file, int line)
void * safe_malloc(size_t size, const char *file, int line)
{
int i;
#if BEST_FIT
/* This is the simplest way possible. Should fix this. */
void * realloc(void * start, size_t newsize)
{
void * newstart = malloc(newsize, __FILE__, __LINE__);
void * newstart = safe_malloc(newsize, __FILE__, __LINE__);
bcopy(start, newstart, newsize);
free(start);
return newstart;

Archive Download the corresponding diff file

Revision: 11