Comments (11)
Simply I am new on GitHub. But OK. I will try to prepare the pull request. However, it may take time until I understand the required steps.
By the way, I tried to compile qlibc under Windows using CMake. Without success. Is it possible to compile qlibc on Windows?
from qlibc.
No, the num
represents the total number of objects stored in the vector. When the resize happen to be smaller size than the stored number of objects, it allows to keep the existing objects but will not allow to insert more objects there until num gets smaller than the max.
from qlibc.
It seems I do not understand how realloc works. In a documentation of realloc, I read: "The content of the memory block is preserved up to the lesser of the new and old sizes". I interpret this, that the existing objects outside of reallocated space are not preserved.
from qlibc.
from qlibc.
I have made a simple test case. Maybe it will help to understand the problem:
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "qlibc.h"
int main(void) {
size_t i;
size_t siz = sizeof(i);
qvector_t *vec = qvector(10, siz, QVECTOR_RESIZE_LINEAR);
for (i=0; i < 5; i++) {
vec->addlast(vec, &i);
}
printf("Number of elements = %zu\n", vec->size(vec));
for (i=0; i < vec->size(vec); i++) {
printf("vec[%zu]=%zu\n", i, *(size_t*) vec->getat(vec, i, false));
}
vec->resize(vec, 3);
printf("New number of elements = %zu\n", vec->size(vec));
for (i=0; i < vec->size(vec); i++) {
printf("vec[%zu]=%zu\n", i, *(size_t*) vec->getat(vec, i, false));
}
vec->free(vec);
return 0;
}
On my PC, I have output (note, the last two lines are with wrong values):
Number of elements = 5
vec[0]=0
vec[1]=1
vec[2]=2
vec[3]=3
vec[4]=4
New number of elements = 5
vec[0]=0
vec[1]=1
vec[2]=2
vec[3]=65
vec[4]=0
from qlibc.
from qlibc.
Better not.
from qlibc.
from qlibc.
from qlibc.
@darmar-lt let us know if you need any help with the pull request :)
from qlibc.
not hearing back so long, closing
from qlibc.
Related Issues (20)
- Memory allocation fail then return NULL? HOT 1
- Problem with qstrreplace() HOT 2
- qconfig_parse_file() input crashes HOT 4
- A problem (?) in qtreetbl HOT 3
- [Question] Windows supported? It seems that CMake doesn't work HOT 6
- Say hello
- qhex_decode segfault HOT 1
- qurl_decode segfault HOT 3
- qtreetbl has right lean child. Is qtreetbl not a llrb? HOT 2
- qvector_t: calling addlast after calling clear causes double free and SIGABRT HOT 5
- Hashtable with non-string keys HOT 1
- Should qlibc support meson and ninja build? HOT 1
- hostname or destname HOT 1
- error: too many arguments to function 'mkdir' HOT 1
- This library is not portable! HOT 2
- qhashmd5_file() reads zero bytes when the entire file is requested
- test_qtreetbl.c will segfault with gcc >= 10 HOT 4
- Error while loading shared libraries: ../lib/libqlibc.so.2: cannot open shared object file: No such file or directory HOT 13
- A potential bug about lock HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qlibc.