Giter Club home page Giter Club logo

libapenetwork-archive's People

Contributors

efyx avatar paraboul avatar verpeteren avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zhangjinde

libapenetwork-archive's Issues

ape_buffer / append_string_n off-by-one error

I was playing around with ape_buffer, and I noticed that append_string_n, did not have the result that I anticpated. But maybe I misunderstood it's usage.
The code below is a small test to reproduce my situation.

/*
 gcc -g test_buffer.c -o test_buffer -isystem ../libapenetwork/ -L ../libapenetwork/ -lnativenetwork
*/
#include <stdio.h>
#include <string.h>
#include <assert.h>

#include "ape_buffer.h"

#define TEXT "Anthony Catel"

int main( int argc, char ** argv ) {
    buffer * string;

    string = NULL;
    string = buffer_new( 6 );
    memset(string->data, '\0', string->size );
    //  should append on a fresh buffer
    buffer_append_string_n( string, TEXT, 2 );
    assert( strcmp( (char *) string->data, "An" ) == 0 && string->used == 2 ); //  becomes Ant
    //  should append some tokens on a used buffer
    buffer_append_string_n( string, TEXT, 3 );
    assert( strcmp( (char *) string->data, "AnAnt" ) == 0 && string->used == 5 ); //  becomes AnAnt
    //  should append some tokens on a almost full buffer
    buffer_append_string_n( string, TEXT, 1 );
    assert( strcmp( (char *) string->data, "AnAntA" ) == 0 && string->used == 6 ); //  becomes AnAntAn

    return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.