Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
0 votes
2 answers
92 views

man 2 brk says: int brk(void *addr); brk() sets the end of the data segment to the value specified by addr ... On success, brk() returns zero. On error, -1 is returned, and errno is set to ENOMEM. ...
1 vote
0 answers
59 views

I am trying to implement a simple memory allocator. Essentially trying to copy the function malloc() and free(void *ptr) in C. I initialize a region of memory using sbrk(). In my custom malloc ...
0 votes
2 answers
95 views

I wrote the following program, #include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <time.h> #include "rand.h" int main (int argc, char* argv[]) { ...
Addem's user avatar
  • 4,013
0 votes
0 answers
112 views

I'm trying to learn MIPS and implement a dynamic memory allocation depending on the size of the number of values I need to store, so I'm using sbrk in my allocation of space. The problem arises that ...
Niv O's user avatar
  • 1
2 votes
1 answer
125 views

I am learning how sbrk, brk, mmap etc work and what they offer. I am writing a very basic code like this int main(int argc, char* argv[]) { void* f1 = sbrk(0); int* newarr = (int*)f1; for(int i=0;...
3 votes
0 answers
105 views

I have an algorithm that requires making two passes a file's data. The file may be stdin or stream (like a |) since this is a command line tool, which makes me unfortunately (to the best of my ...
1 vote
0 answers
66 views

Based on info in https://man7.org/linux/man-pages/man2/brk.2.html, the brk Linux system call works like this: void *sys_brk(void *desired_break) { return (void*)syscall(SYS_brk, desired_break); } It ...
pts's user avatar
  • 88.7k
-1 votes
1 answer
134 views

This code segfaults on line 97 (according to gdb) on one machine (Linode) yet runs just fine on a different machine (personal) and I haven't really been able to figure out why. I tried ensuring that ...
0 votes
1 answer
61 views

I'm trying to recode a mini malloc using sbrk() and implementing a best-fit algorithm. I added a main to test my malloc along with my free(). Next thing a Segfault even though some of the values I ...
-1 votes
2 answers
753 views

While working with glibc I tried to reduce the data segment using sbrk using a negative parameter, and found a most strange behaviour. I first malloc, then free it, then reduce data segment with sbrk, ...
Arc's user avatar
  • 462
3 votes
2 answers
1k views

For learning purposes, I'm trying to implement a stack in the heap memory. When I push something I just need to do the systemcall sbrk, and that's fine. When I proceed with a pop I can retrive my ...
0 votes
0 answers
224 views

So I call sbrk like this: void *return_value = sbrk(1024); And when I debug it is giving me this error on that specific line: __GI___sbrk (increment=1024) at sbrk.c:32 32 sbrk.c: No such file or ...
Art smart's user avatar
8 votes
4 answers
7k views

Ever since I was introduced to C, I was told that in C dynamic memory allocation is done using the functions in the malloc family. I also learned that memory dynamically allocated using malloc is ...
1 vote
0 answers
454 views

Could someone please tell me how to solve this problem described in the title? I've searched for a long time but still not found a solution yet. Update: I'm using window system
o o's user avatar
  • 165
0 votes
1 answer
234 views

On ubuntu 18.04 I wrote the following c program and ran it with an input of 100 #include <stdio.h> #include <stdlib.h> #include <unistd.h> int main() { int x; scanf("%d&...
user avatar

15 30 50 per page
1
2 3 4 5
...
7

AltStyle によって変換されたページ (->オリジナル) /