grub2: bring back build of aros-side grub2 tools
[AROS.git] / workbench / libs / popupmenu / pmmem.c
blob618909a88ce577df970e6faf840a10dd72aaddb4
1 //
2 // pmmem.h
3 //
5 #include "pmpriv.h"
6 #include "pmmem.h"
8 APTR PM_AllocVecPooled(LONG size)
10 #if defined(__AROS__) || defined(__MORPHOS__)
11 ULONG *p;
13 // To Do: Add Semaphore protection to the pool!!!
14 // stegerg: MOS and AROS have MEMF_SEM_PROTECTED. See pminit.c
16 size += sizeof(ULONG);
18 p = AllocPooled(MemPool, size);
19 if(p) {
20 *p++ = size;
21 return (APTR)p;
23 return NULL;
24 #else
25 return AllocVec(size, MEMF_CLEAR);
26 #endif
29 void PM_FreeVecPooled(APTR mem)
31 #if defined(__AROS__) || defined(__MORPHOS__)
32 ULONG *p = (ULONG *)mem;
33 p--;
34 FreePooled(MemPool, p, *p);
35 #else
36 FreeVec(mem);
37 #endif
40 ULONG PM_String_Length(STRPTR s)
42 IPTR r=(IPTR)s;
44 while(*s++);
46 return ((IPTR)s)-r;
49 STRPTR PM_String_Copy(STRPTR Source, STRPTR Dest, LONG Len)
51 if(Len==-1) {
52 while(*Source) *Dest++=*Source++;
53 *Dest++=0;
54 return Dest;
55 } else {
56 LONG ctr=0;
58 while(ctr<Len) {
59 Dest[ctr]=Source[ctr];
60 ctr++;
62 return &Dest[ctr];
66 ULONG PM_String_Compare(STRPTR str1, STRPTR str2)
68 ULONG i, j=0;
69 if(!str1 || !str2) return 0;
70 for(i=0;;i++) {
71 j+=str1[i];
72 j-=str2[i];
73 if(!str1[i] || !str2[i] || j) return j;
77 void PM_StrCat(STRPTR str1, STRPTR str2)
79 while(*str1) str1++;
80 while(*str2) *str1++=*str2++;
81 *str1=0;