Navigation Menu

Skip to content

Commit

Permalink
windows: use strncpy_s() on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Apr 15, 2015
1 parent 3283f43 commit 1ca380c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 8 additions & 0 deletions include/groonga/portability.h
Expand Up @@ -91,4 +91,12 @@
strncat((dest), (src), (n))
#endif /* WIN32 */

#ifdef WIN32
# define grn_strncpy(dest, dest_size, src, n) \
strncpy_s((dest), (dest_size), (src), (n))
#else /* WIN32 */
# define grn_strncpy(dest, dest_size, src, n) \
strncpy((dest), (src), (n))
#endif /* WIN32 */

#endif /* GROONGA_PORTABILITY_H */
5 changes: 4 additions & 1 deletion lib/db.c
Expand Up @@ -7505,7 +7505,10 @@ grn_obj_set_info_source_validate_report_error(grn_ctx *ctx,
GRN_TABLE_MAX_KEY_SIZE);
grn_obj_unlink(ctx, source_type);
} else {
strncpy(source_type_name, "(nil)", GRN_TABLE_MAX_KEY_SIZE);
grn_strncpy(source_type_name,
GRN_TABLE_MAX_KEY_SIZE,
"(nil)",
GRN_TABLE_MAX_KEY_SIZE);
source_type_name_size = strlen(source_type_name);
}
ERR(GRN_INVALID_ARGUMENT,
Expand Down
4 changes: 2 additions & 2 deletions lib/io.c
Expand Up @@ -301,7 +301,7 @@ grn_io_create(grn_ctx *ctx, const char *path, uint32_t header_size, uint32_t seg
if ((io = GRN_GMALLOCN(grn_io, 1))) {
grn_io_mapinfo *maps = NULL;
if ((maps = GRN_GCALLOC(sizeof(grn_io_mapinfo) * max_segment))) {
strncpy(io->path, path, PATH_MAX);
grn_strncpy(io->path, PATH_MAX, path, PATH_MAX);
io->header = header;
io->user_header = (((byte *) header) + IO_HEADER_SIZE);
io->maps = maps;
Expand Down Expand Up @@ -553,7 +553,7 @@ grn_io_open(grn_ctx *ctx, const char *path, grn_io_mode mode)
if ((io = GRN_GMALLOC(sizeof(grn_io)))) {
grn_io_mapinfo *maps = NULL;
if ((maps = GRN_GCALLOC(sizeof(grn_io_mapinfo) * max_segment))) {
strncpy(io->path, path, PATH_MAX);
grn_strncpy(io->path, PATH_MAX, path, PATH_MAX);
io->header = header;
io->user_header = (((byte *) header) + IO_HEADER_SIZE);
{
Expand Down

0 comments on commit 1ca380c

Please sign in to comment.