|
1 | | -/* Picasso - a vector graphics library |
| 1 | +/* |
| 2 | + * Copyright (c) 2026, Zhang Ji Peng |
| 3 | + * All rights reserved. |
2 | 4 | * |
3 | | - * Copyright (C) 2010 Zhang Ji Peng |
4 | | - * Contact: onecoolx@gmail.com |
| 5 | + * Redistribution and use in source and binary forms, with or without |
| 6 | + * modification, are permitted provided that the following conditions are met: |
| 7 | + * |
| 8 | + * * Redistributions of source code must retain the above copyright notice, this |
| 9 | + * list of conditions and the following disclaimer. |
| 10 | + * |
| 11 | + * * Redistributions in binary form must reproduce the above copyright notice, |
| 12 | + * this list of conditions and the following disclaimer in the documentation |
| 13 | + * and/or other materials provided with the distribution. |
| 14 | + * |
| 15 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 16 | + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 17 | + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 18 | + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| 19 | + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 20 | + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 21 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 22 | + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 23 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
5 | 25 | */ |
6 | 26 |
|
7 | 27 | #ifndef _MEMORY_MANAGER_H_ |
|
11 | 31 | #include <stdlib.h> |
12 | 32 | #include <stdint.h> |
13 | 33 |
|
| 34 | +#include "global.h" |
14 | 35 | #include "fastcopy.h" |
15 | 36 |
|
16 | 37 | // common memory managers |
17 | 38 |
|
18 | | -#define mem_malloc(n) malloc(n) |
19 | | -#define mem_calloc(n, s) calloc(n, s) |
20 | | -#define mem_free(p) free(p) |
| 39 | +#define mem_malloc(n) (picasso::_global._malloc((n))) |
| 40 | +#define mem_calloc(n, s) (picasso::_global._calloc((n), (s))) |
| 41 | +#define mem_free(p) (picasso::_global._free((p))) |
21 | 42 |
|
22 | 43 | #define mem_deep_copy(d, s, l) memmove(d, s, l) |
23 | 44 | #define mem_copy(d, s, l) fastcopy(d, s, l) |
24 | 45 |
|
| 46 | +// this can be replace by hw buffer! |
| 47 | +#define BufferAlloc(n) mem_calloc(n, 1) |
| 48 | +#define BuffersAlloc(n, s) mem_calloc(n, s) |
| 49 | +#define BufferFree(p) mem_free(p) |
| 50 | +#define BufferCopy(d, s, n) mem_copy(d, s, n) |
| 51 | + |
25 | 52 | #if !ENABLE(SYSTEM_MALLOC) && !COMPILER(CLANG) |
26 | 53 | #undef new |
27 | 54 | #undef delete |
|
0 commit comments