Skip to content

Commit

Permalink
Adding locacl changes
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Oct 14, 2013
1 parent 812f30b commit 614fedc
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 56 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.o
*.pyc
bin/
deps/
*.swp

4 changes: 2 additions & 2 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>--variant=debug</value>
<value>--variant=clang_debug</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
<value>${ProjDirPath}/build.sh</value>
<value>${ProjDirPath}/build</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
Expand Down
53 changes: 0 additions & 53 deletions tests/camio2_test_buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,65 +12,12 @@ USE_M6_LOGGER(M6_LOG_LVL_DEBUG3,1,M6_LOG_OUT_STDERR,"");
USE_M6_OPTIONS;
USE_M6_PERF(1);

typedef struct {
char* str;
m6_bool is_const;
i64 slen;
i64 mlen;
} m6_str;

#define M6_STR_CONST_NEW(name, s) m6_str name = M6_STR_CONST_LIT(s)
#define M6_STR_CONST_LIT(s) { .str = s, .is_const = 1, .slen = strlen(s), .mlen = strlen(s) }
#define M6_STR_CONST_FUNC(s) { .str = s, is_const = -1, .slen = -1, }

//Make a new m6_string on the stack, no free is necessary when done with it, but don,t pass it up a function call
m6_str m6_str_new_stack_s(char* s,i64 size){
m6_str result;
result.mlen = MIN(size + 1,getpagesize()); //Put a sensible bound on the size of these things
result.slen = strnlen(s,size);
if(unlikely(result.slen > result.mlen - 1)){
result.slen = size - 1;
}

result.str = (char*)alloca(result.mlen);
result.str[result.mlen -1] = '\0'; //Always null terminate the whole thing
memcpy(result.str,s,result.slen);//Also null terminate the actual string.
result.str[result.slen] = '\0';
result.is_const = 1;

return result;
}

//Make a new m6_string on the heap, you need to free it when done with it
m6_str m6_str_new_heap_s(char* s,i64 size){
m6_str result;
result.mlen = MIN(size + 1,getpagesize()); //Put a sensible bound on the size of these things
result.slen = strnlen(s,size);
if(unlikely(result.slen > result.mlen - 1)){
result.slen = size - 1;
}

result.str = (char*)malloc(result.mlen);
result.str[result.mlen -1] = '\0'; //Always null terminate the whole thing
memcpy(result.str,s,result.slen);
result.str[result.slen] = '\0';//Aslo null terminate the actual string
result.is_const = 0;

return result;
}

//Concatenate two strings and return a string on the stack (no need to free it)
m6_str m6_str_cat_stack(m6_str lhs, m6_str rhs){

}



void test_camio2_buffer_malloc()
{

M6_STR_CONST_NEW(test,"");

printf("Running buffer_malloc tests..\n");
m6_log_info("Running malloc buffer test 1...\n");
camio2_buffer_t* test_buff1 = camio2_buffer_malloc_new(0,0);
Expand Down

0 comments on commit 614fedc

Please sign in to comment.