Couchbase Lite C
Couchbase Lite C API
Data Structures | Macros | Typedefs | Functions
FLSlice.h File Reference
#include "Base.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Data Structures

struct  FLSlice
 A simple reference to a block of memory. More...
 
struct  FLSliceResult
 A heap-allocated block of memory returned from an API call. More...
 

Macros

#define _FLSLICE_H
 
#define FLAPI
 
#define kFLSliceNull   ((FLSlice){NULL, 0})
 A convenient constant denoting a null slice. More...
 
#define FLSTR(STR)   ((FLSlice){("" STR), sizeof(("" STR))-1})
 Macro version of FLStr, for use in initializing compile-time constants. More...
 

Typedefs

typedef FLSlice FLHeapSlice
 A heap-allocated, reference-counted slice. More...
 
typedef FLSlice FLString
 
typedef FLSliceResult FLStringResult
 

Functions

static FLPURE int FLMemCmp (const void *a, const void *b, size_t size)
 Exactly like memcmp, but safely handles the case where a or b is NULL and size is 0 (by returning 0), instead of producing "undefined behavior" as per the C spec. More...
 
static void FLMemCpy (void *dst, const void *src, size_t size)
 Exactly like memcmp, but safely handles the case where dst or src is NULL and size is 0 (as a no-op), instead of producing "undefined behavior" as per the C spec. More...
 
static FLSlice FLStr (const char *str)
 Returns a slice pointing to the contents of a C string. More...
 
bool FLSlice_Equal (FLSlice a, FLSlice b) FLPURE
 Equality test of two slices. More...
 
int FLSlice_Compare (FLSlice, FLSlice) FLPURE
 Lexicographic comparison of two slices; basically like memcmp(), but taking into account differences in length. More...
 
uint32_t FLSlice_Hash (FLSlice s) FLPURE
 Computes a 32-bit hash of a slice's data, suitable for use in hash tables. More...
 
bool FLSlice_ToCString (FLSlice s, char *buffer, size_t capacity)
 Copies a slice to a buffer, adding a trailing zero byte to make it a valid C string. More...
 
FLSliceResult FLSliceResult_New (size_t)
 Allocates an FLSliceResult of the given size, without initializing the buffer. More...
 
FLSliceResult FLSlice_Copy (FLSlice)
 Allocates an FLSliceResult, copying the given slice. More...
 
static FLSliceResult FLSliceResult_CreateWith (const void *bytes, size_t size)
 Allocates an FLSliceResult, copying size bytes starting at buf. More...
 
void _FLBuf_Retain (const void *)
 
void _FLBuf_Release (const void *)
 
static FLSliceResult FLSliceResult_Retain (FLSliceResult s)
 Increments the ref-count of a FLSliceResult. More...
 
static void FLSliceResult_Release (FLSliceResult s)
 Decrements the ref-count of a FLSliceResult, freeing its memory if it reached zero. More...
 
static FLSlice FLSliceResult_AsSlice (FLSliceResult sr)
 Type-casts a FLSliceResult to FLSlice, since C doesn't know it's a subclass. More...
 
void FL_WipeMemory (void *dst, size_t size)
 Writes zeroes to size bytes of memory starting at dst. More...
 

Macro Definition Documentation

◆ _FLSLICE_H

#define _FLSLICE_H

◆ FLAPI

#define FLAPI