aboutsummaryrefslogtreecommitdiffstats
path: root/src/mac.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2006-04-18 08:11:56 +0000
committerYAMAMOTO Mitsuharu2006-04-18 08:11:56 +0000
commit305366a3bc26d31f30965aaf16ed4ea3835b3564 (patch)
treeed837493b1da3f367ba63bfb755679bb0ee4d683 /src/mac.c
parent1caa0b53a041b8cbf38aad43a90a8bf29349265c (diff)
downloademacs-305366a3bc26d31f30965aaf16ed4ea3835b3564.tar.gz
emacs-305366a3bc26d31f30965aaf16ed4ea3835b3564.zip
(mac_coerce_file_name_ptr, mac_coerce_file_name_desc)
(create_apple_event_from_event_ref, xrm_get_preference_database) (cfstring_create_normalized): Don't check return value of xmalloc.
Diffstat (limited to 'src/mac.c')
-rw-r--r--src/mac.c71
1 files changed, 24 insertions, 47 deletions
diff --git a/src/mac.c b/src/mac.c
index 2b4e8dcbc64..7172301b6b0 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -453,15 +453,10 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
453 char *buf; 453 char *buf;
454 454
455 buf = xmalloc (data_size + 1); 455 buf = xmalloc (data_size + 1);
456 if (buf) 456 memcpy (buf, data_ptr, data_size);
457 { 457 buf[data_size] = '\0';
458 memcpy (buf, data_ptr, data_size); 458 err = posix_pathname_to_fsspec (buf, &fs);
459 buf[data_size] = '\0'; 459 xfree (buf);
460 err = posix_pathname_to_fsspec (buf, &fs);
461 xfree (buf);
462 }
463 else
464 err = memFullErr;
465 if (err == noErr) 460 if (err == noErr)
466 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result); 461 err = AECoercePtr (typeFSS, &fs, sizeof (FSSpec), to_type, result);
467#endif 462#endif
@@ -489,14 +484,11 @@ mac_coerce_file_name_ptr (type_code, data_ptr, data_size,
489 { 484 {
490 size = AEGetDescDataSize (&desc); 485 size = AEGetDescDataSize (&desc);
491 buf = xmalloc (size); 486 buf = xmalloc (size);
492 if (buf) 487 err = AEGetDescData (&desc, buf, size);
493 { 488 if (err == noErr)
494 err = AEGetDescData (&desc, buf, size); 489 url = CFURLCreateWithBytes (NULL, buf, size,
495 if (err == noErr) 490 kCFStringEncodingUTF8, NULL);
496 url = CFURLCreateWithBytes (NULL, buf, size, 491 xfree (buf);
497 kCFStringEncodingUTF8, NULL);
498 xfree (buf);
499 }
500 AEDisposeDesc (&desc); 492 AEDisposeDesc (&desc);
501 } 493 }
502 } 494 }
@@ -581,21 +573,16 @@ mac_coerce_file_name_desc (from_desc, to_type, handler_refcon, result)
581 data_size = GetHandleSize (from_desc->dataHandle); 573 data_size = GetHandleSize (from_desc->dataHandle);
582#endif 574#endif
583 data_ptr = xmalloc (data_size); 575 data_ptr = xmalloc (data_size);
584 if (data_ptr)
585 {
586#if TARGET_API_MAC_CARBON 576#if TARGET_API_MAC_CARBON
587 err = AEGetDescData (from_desc, data_ptr, data_size); 577 err = AEGetDescData (from_desc, data_ptr, data_size);
588#else 578#else
589 memcpy (data_ptr, *(from_desc->dataHandle), data_size); 579 memcpy (data_ptr, *(from_desc->dataHandle), data_size);
590#endif 580#endif
591 if (err == noErr) 581 if (err == noErr)
592 err = mac_coerce_file_name_ptr (from_type, data_ptr, 582 err = mac_coerce_file_name_ptr (from_type, data_ptr,
593 data_size, to_type, 583 data_size, to_type,
594 handler_refcon, result); 584 handler_refcon, result);
595 xfree (data_ptr); 585 xfree (data_ptr);
596 }
597 else
598 err = memFullErr;
599 } 586 }
600 587
601 if (err != noErr) 588 if (err != noErr)
@@ -691,8 +678,6 @@ create_apple_event_from_event_ref (event, num_params, names, types, result)
691 if (err != noErr) 678 if (err != noErr)
692 break; 679 break;
693 buf = xmalloc (size); 680 buf = xmalloc (size);
694 if (buf == NULL)
695 break;
696 err = GetEventParameter (event, names[i], types[i], NULL, 681 err = GetEventParameter (event, names[i], types[i], NULL,
697 size, NULL, buf); 682 size, NULL, buf);
698 if (err == noErr) 683 if (err == noErr)
@@ -1596,8 +1581,6 @@ xrm_get_preference_database (application)
1596 1581
1597 count = CFSetGetCount (key_set); 1582 count = CFSetGetCount (key_set);
1598 keys = xmalloc (sizeof (CFStringRef) * count); 1583 keys = xmalloc (sizeof (CFStringRef) * count);
1599 if (keys == NULL)
1600 goto out;
1601 CFSetGetValues (key_set, (const void **)keys); 1584 CFSetGetValues (key_set, (const void **)keys);
1602 for (index = 0; index < count; index++) 1585 for (index = 0; index < count; index++)
1603 { 1586 {
@@ -4547,11 +4530,8 @@ cfstring_create_normalized (str, symbol)
4547 if (in_text == NULL) 4530 if (in_text == NULL)
4548 { 4531 {
4549 buffer = xmalloc (sizeof (UniChar) * length); 4532 buffer = xmalloc (sizeof (UniChar) * length);
4550 if (buffer) 4533 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4551 { 4534 in_text = buffer;
4552 CFStringGetCharacters (str, CFRangeMake (0, length), buffer);
4553 in_text = buffer;
4554 }
4555 } 4535 }
4556 4536
4557 if (in_text) 4537 if (in_text)
@@ -4559,15 +4539,12 @@ cfstring_create_normalized (str, symbol)
4559 while (err == noErr) 4539 while (err == noErr)
4560 { 4540 {
4561 out_buf = xmalloc (out_size); 4541 out_buf = xmalloc (out_size);
4562 if (out_buf == NULL) 4542 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar),
4563 err = mFulErr; 4543 in_text,
4564 else 4544 kUnicodeDefaultDirectionMask,
4565 err = ConvertFromUnicodeToText (uni, length * sizeof (UniChar), 4545 0, NULL, NULL, NULL,
4566 in_text, 4546 out_size, &out_read, &out_len,
4567 kUnicodeDefaultDirectionMask, 4547 out_buf);
4568 0, NULL, NULL, NULL,
4569 out_size, &out_read, &out_len,
4570 out_buf);
4571 if (err == noErr && out_read < length * sizeof (UniChar)) 4548 if (err == noErr && out_read < length * sizeof (UniChar))
4572 { 4549 {
4573 xfree (out_buf); 4550 xfree (out_buf);