mirror of
https://gitee.com/apaki/unicstl.git
synced 2026-05-29 07:04:20 +08:00
79 lines
1.2 KiB
C
79 lines
1.2 KiB
C
/**
|
|
* @file unicstl_internal.h
|
|
* @author wenjf (Orig5826@163.com)
|
|
* @brief
|
|
* @version 0.1
|
|
* @date 2025-04-30
|
|
*
|
|
* @copyright Copyright (c) 2025
|
|
*
|
|
*/
|
|
#ifndef _COMMON_H_
|
|
#define _COMMON_H_
|
|
|
|
#define UNICSTL_CONFIG
|
|
|
|
#ifdef UNICSTL_CONFIG
|
|
#include "unicstl_config.h"
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
#include <assert.h>
|
|
|
|
#ifdef UNICSTL_ITERATOR
|
|
#include "iterator.h"
|
|
#endif
|
|
|
|
|
|
/**
|
|
* @brief default capacity and ratio
|
|
*
|
|
*/
|
|
#define DEFAULT_CAPACITY 16
|
|
#define DEFAULT_RATIO 2
|
|
|
|
|
|
/**
|
|
* @brief malloc and free function
|
|
*
|
|
*/
|
|
#ifdef UNICSTL_MALLOC
|
|
static inline void * unicstl_malloc(size_t size) {
|
|
return malloc(size);
|
|
}
|
|
|
|
static inline void * unicstl_realloc(void * ptr, size_t size) {
|
|
return realloc(ptr, size);
|
|
}
|
|
|
|
static inline void unicstl_free(void * ptr) {
|
|
free(ptr);
|
|
}
|
|
#else
|
|
#error "UNICSTL_MALLOC not defined"
|
|
#endif
|
|
|
|
|
|
/**
|
|
* @brief obj compare with obj2
|
|
*
|
|
* @return
|
|
* obj < obj2 return -1
|
|
* obj == obj2 return 0
|
|
* obj > obj2 return 1
|
|
*/
|
|
typedef int (*compare_fun_t)(void* obj, void* obj2);
|
|
|
|
|
|
// default function
|
|
int default_compare(void* obj1, void* obj2);
|
|
void default_print_obj(void* obj);
|
|
|
|
|
|
#endif // _COMMON_H_
|