New bitmap method SetRGBConversionFunction which can be used to
[tangerine.git] / workbench / libs / rexxsupport / allocmem.c
blob29aed8cfd424216e2f4322a0a3dd851c582a46cc
1 /*
2 Copyright © 1995-2002, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Rexx stub for AllocMem system function
6 Lang: English
7 */
9 #include <proto/exec.h>
10 #include <proto/rexxsyslib.h>
11 #include <exec/types.h>
12 #include <exec/memory.h>
13 #include <rexx/storage.h>
14 #include <rexx/errors.h>
16 #include <ctype.h>
17 #include <stdlib.h>
19 #include "rexxsupport_intern.h"
20 #include "rxfunctions.h"
22 LONG rxsupp_allocmem(struct Library *RexxSupportBase, struct RexxMsg *msg, UBYTE **argstring)
24 char *end;
25 ULONG size;
26 void *mem;
27 ULONG attributes = MEMF_PUBLIC;
29 if ((msg->rm_Action & RXARGMASK) == 2)
31 if (LengthArgstring(ARG2(msg)) != 4)
33 *argstring = NULL;
34 return ERR10_018;
36 else
38 /* This value has always has to be given in little endian to keep arexx
39 * scripts portable */
40 UBYTE *bytes = ARG2(msg);
41 attributes = (ULONG)bytes[0]<<24 | (ULONG)bytes[1]<<16 | (ULONG)bytes[2]<<8 | (ULONG)bytes[3];
44 size = strtoul(ARG1(msg), &end, 10);
45 while (isspace(*end)) end++;
46 if (*end != 0)
48 *argstring = NULL;
49 return ERR10_018;
51 mem = AllocMem(size, attributes);
52 if (mem==NULL)
54 *argstring = NULL;
55 return ERR10_003;
57 else
59 *argstring = CreateArgstring((UBYTE *)&mem, sizeof(void *));
60 return 0;