summaryrefslogtreecommitdiff
path: root/zap/include/zap/mem.h
blob: 8646d63abbb1625e797d48d9f1d5118f7f7b5554 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
	Copyright 2022 Gabriel Jensen.
	This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
	If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/

#if !defined(zap_priv_hdr_mem)
#define zap_priv_hdr_mem

#include <zap/bs.h>

#if defined(__cplusplus)
extern "C" {
#endif

typedef struct {
	void * ptr;
	zap_sz sz;
} zap_mem;

__attribute__ ((hot,warn_unused_result))         zap_sz   zap_memcnt(    void const *      ptr,  zap_sz       sz,  zap_sz        num,   zap_bool (* fn)(void const *));
__attribute__ ((hot,nothrow))                    zap_sz   zap_memcp(     void const *      in,   zap_sz       num, void *        out);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_memeq(     void const *      lptr, zap_sz       num, void const *  rptr);
__attribute__ ((hot,nothrow))                    zap_sz   zap_memfill(   void *            ptr,  zap_sz       num, unsigned char val);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz   zap_memfnd(    void const *      ptr,  zap_sz       num, unsigned char byte);
__attribute__ ((hot))                            void     zap_memfor(    void *            ptr,  zap_sz       sz,  zap_sz        num,   void (*     fn)(void *));
__attribute__ ((hot))                            void     zap_memgen(    void *            ptr,  zap_sz       sz,  zap_sz        num,   void (*     fn)(zap_sz,void *));
__attribute__ ((hot,nothrow))                    zap_sz   zap_strcp(     char const *      in,   char *       out);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_bool zap_streq(     char const *      lstr, char const * rstr);
__attribute__ ((hot,nothrow))                    zap_sz   zap_strfill(   char *            lstr, char         chr);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz   zap_strfnd(    char const *      str,  char         chr);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz   zap_strlen(    char const *      str);
__attribute__ ((hot,nothrow,warn_unused_result)) zap_sz   zap_utf20len(  zap_chr20 const * utf20);
__attribute__ ((hot,nothrow))                    void     zap_utf8dec(   zap_chr8 const *  in,   zap_chr20 *  out);
__attribute__ ((hot,nothrow))                    zap_sz   zap_utf8declen(zap_chr8 const *  utf8);
__attribute__ ((hot,nothrow))                    void     zap_utf8enc(   zap_chr20 const * in,   zap_chr8 *   out);
__attribute__ ((hot,nothrow))                    zap_sz   zap_utf8enclen(zap_chr20 const * utf20);
__attribute__ ((hot,nothrow))                    void     zap_win1252dec(zap_chr8 const *  in,   zap_chr20 *  out);
__attribute__ ((hot,nothrow))                    void     zap_win1252enc(zap_chr20 const * in,   zap_chr8 *   out);

#if defined(__cplusplus)
}
#endif

#endif