Skip to content

Commit

Permalink
Fix UBSAN warning in ldat
Browse files Browse the repository at this point in the history
  • Loading branch information
djvanderlaan committed May 23, 2018
1 parent e2914c9 commit e749996
Show file tree
Hide file tree
Showing 20 changed files with 17 additions and 35 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: lvec
Type: Package
Title: Out of Memory Vectors
Version: 0.2.1
Date: 2018-05-15
Version: 0.2.2
Date: 2018-05-23
Author: Jan van der Laan
Maintainer: Jan van der Laan <djvanderlaan@unrealizedtime.nl>
Description: Core functionality for working with vectors (numeric, integer,
Expand Down
2 changes: 1 addition & 1 deletion inst/include/tempfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
inline std::string tempfile() {
static std::string(*fun)() = NULL;
if (fun == NULL)
fun = (std::string(*)()) R_GetCCallable("lvec", "tempfile");
fun = (std::string(*)()) R_GetCCallable("lvec", "tempfile_impl");
return fun();
}

Expand Down
1 change: 0 additions & 1 deletion src/as_lvec.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"
#include <cstring>

Expand Down
2 changes: 0 additions & 2 deletions src/as_rvec.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include "../inst/include/lvec.h"

#include "r_export.h"
#include <cstring>

Expand Down
1 change: 0 additions & 1 deletion src/assign.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

class assign_visitor : public ldat::lvec_visitor {
Expand Down
1 change: 0 additions & 1 deletion src/assign_range.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

class assign_range_visitor : public ldat::lvec_visitor {
Expand Down
1 change: 0 additions & 1 deletion src/clone.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

RcppExport SEXP lclone(SEXP rv) {
Expand Down
1 change: 0 additions & 1 deletion src/construct.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

RcppExport SEXP new_lvec(SEXP rsize, SEXP rtype, SEXP rstrlen) {
Expand Down
1 change: 0 additions & 1 deletion src/get_type.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

class type_visitor : public ldat::lvec_visitor {
Expand Down
1 change: 0 additions & 1 deletion src/indexing.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"
#include <memory>

Expand Down
3 changes: 1 addition & 2 deletions src/indexing_range.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "../inst/include/lvec.h"
#include <memory>
#include "r_export.h"
#include <memory>

class range_indexing_visitor : public ldat::lvec_visitor {
public:
Expand Down
6 changes: 2 additions & 4 deletions src/lvec-init.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#include "tempfile.h"
#include "../inst/include/lvec.h"
#include "r_export.h"
#include "tempfile_impl.h"

#include <R_ext/Rdynload.h>


#define CALLDEF(name, n) {#name, (DL_FUNC) &name, n}

extern "C" {
Expand All @@ -29,7 +27,7 @@ extern "C" {
};

void R_init_lvec(DllInfo *info) {
R_RegisterCCallable("lvec", "tempfile", (DL_FUNC) &tempfile);
R_RegisterCCallable("lvec", "tempfile_impl", (DL_FUNC) &tempfile_impl);
R_registerRoutines(info, NULL, r_calldef, NULL, NULL);
R_useDynamicSymbols(info, static_cast<Rboolean>(FALSE));
}
Expand Down
1 change: 0 additions & 1 deletion src/order.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

#include <algorithm>
Expand Down
3 changes: 1 addition & 2 deletions src/r_export.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "../inst/include/cppr.h"
#include "../inst/include/lvec.h"
#include "../inst/include/lvec_interface.h"

extern "C" {
SEXP as_lvec(SEXP rv);
Expand Down
1 change: 0 additions & 1 deletion src/size.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

RcppExport SEXP get_size(SEXP rv) {
Expand Down
1 change: 0 additions & 1 deletion src/sort.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

#include <algorithm>
Expand Down
1 change: 0 additions & 1 deletion src/strlen.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "../inst/include/lvec.h"
#include "r_export.h"

class strlen_visitor : public ldat::lvec_visitor {
Expand Down
8 changes: 0 additions & 8 deletions src/tempfile.h

This file was deleted.

5 changes: 2 additions & 3 deletions src/tempfile.cpp → src/tempfile_impl.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include "tempfile.h"
#include "../inst/include/cppr.h"
#include "r_export.h"
#include "tempfile_impl.h"

std::string tempdir = ".";

std::string tempfile() {
std::string tempfile_impl() {
char* p = R_tmpnam("lvec", tempdir.c_str());
std::string res{p};
free(p);
Expand Down
8 changes: 8 additions & 0 deletions src/tempfile_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef tempfile_impl_h
#define tempfile_impl_h

#include <string>

std::string tempfile_impl();

#endif

0 comments on commit e749996

Please sign in to comment.