Example #1
0
void *
OS_malloc (size_t size)
{
  void * result = (OS2_malloc_noerror (size));
  if (result == 0)
    OS2_error_system_call (ERROR_NOT_ENOUGH_MEMORY, syscall_malloc);
  return (result);
}
Example #2
0
msg_t *
OS2_create_message_1 (msg_type_t type, msg_length_t extra)
{
  /* Do allocation carefully to prevent infinite loop when signalling
     "out of memory" condition.  */
  msg_t * message =
    (OS2_malloc_noerror (((unsigned long) (OS2_message_type_length (type)))
			 + extra));
  if (message == 0)
    if ((type == mt_syscall_error)
	&& ((SM_SYSCALL_ERROR_CODE (message)) == ERROR_NOT_ENOUGH_MEMORY)
	&& ((SM_SYSCALL_ERROR_NAME (message)) == syscall_malloc))
      OS2_logic_error ("Unable to allocate memory for error message.");
    else
      OS2_error_system_call (ERROR_NOT_ENOUGH_MEMORY, syscall_malloc);
  (MSG_TYPE (message)) = type;
  return (message);
}
Example #3
0
void *
OS2_realloc_noerror (void * ptr, unsigned long size)
{
  unsigned long osize = ((guarantee_valid_malloc_pointer (ptr)) -> size);
  if (osize == size)
    return (ptr);
  {
    void * result = (OS2_malloc_noerror (size));
    if (result != 0)
      {
	char * scan1 = ptr;
	char * end1 = (scan1 + ((osize < size) ? osize : size));
	char * scan2 = result;
	while (scan1 < end1)
	  (*scan2++) = (*scan1++);
	OS_free (ptr);
      }
    return (result);
  }
}
Example #4
0
void *
OS_malloc_init (size_t size)
{
  return (OS2_malloc_noerror (size));
}